Skip to content

How to compute a new result whenever any of the given source streams changes? #6626

Answered by jzarzeckis
jzarzeckis asked this question in Q&A
Discussion options

You must be logged in to vote

Just so this can be closed as "answered", let me mark the IMHO correct approach in a separate comment:

const a = cold('a', { a: 5 });
const b = cold('a-b', { a: 7, b: 3 });

const abSum = combineLatest([a, b]).pipe(map(([a, b]) => a + b));
const abbSum = combineLatest([abSum, b]).pipe(
    auditTime(0, asapScheduler),
    map(([a, b]) => a + b)
);

expectObservable(abbSum).toBe('a-b', { a: 19, b: 11 }); // PASS

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@voliva
Comment options

@jzarzeckis
Comment options

@jzarzeckis
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jzarzeckis
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