Skip to content

How to think about derived streams in rxjs (following FRP)? #7375

Answered by voliva
csenio asked this question in Q&A
Discussion options

You must be logged in to vote

Your attempt is only missing startWith() on both teamValue$ and memberValue$ to set the initial value. Otherwise combineLatest just waits until both have changed (and memberValue$ can't change since the options are not populated)

Usually the way I go about it is having a clear distinction on what are events and what is state. Everything that's state, I make it a multicast observable (with something as shareReplay(1), but you can use many others). And events stay as cold observables.

And everything else is just a matter of composing observables further down the chain. I have implemented this in a fork of your sandbox https://codesandbox.io/s/derived-state-rxjs-forked-7sd7tt?file=/src/index…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by csenio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants