DEV Community

Discussion on: If Svelte and RxJS had a baby

Collapse
 
rohling profile image
Adair Rohling

Very good to know. Thanks a lot...
You write: "Later I will show you another way of handling this."
What another way to start a value, using the same example with array?

Collapse
 
codechips profile image
Ilia Mikhailov

I probably meant that instead of plain observables it's sometimes more convenient to use Rx subjects as you can define them with default values, in this case an empty array, like new BehaviorSubject([]) that also can act as an observable. This way it won't blow up when you subscribe and try to loop over it in Svelte since initial value is an empty array and not null. You can however achieve same thing with RxJS startWith([]) operator and plain observables too if you want.