'Concat list and observable list

Let's say I have 3 lists. Two of them are basic lists while the last one is an observable.

The issue is I now want to merge a non-observable list into the observable one.
Right now I do something like this but I feel like it's "against observables' nature"

listToMerge = []
listObs$: BehaviorSubject<[]> = new BehaviorSubject([]);
listObsCopy = []

I already added some elements in the listObs with the next method

listObs$.next(someStuff);
listObsCopy = somestuff;

Here is my attempt to merge them.

listToMerge = listObsCopy.concat(someOtherStuff);
listObs$.next(listToMerge as any);


Solution 1:[1]

You can easily create an observable from your array to then concat them using the from() function:

https://www.learnrxjs.io/learn-rxjs/operators/creation/from

const arraySource = from([1, 2, 3, 4, 5]);
const arraySource2 = from([6, 7, 8]);
arraySource.concat(arraySource2).subscribe()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark van Straten