kosich / rxjs-autorun

Re-evaluate an expression whenever Observable in it emits
MIT License
34 stars 2 forks source link

Cover multiple sync emissions #33

Open kosich opened 3 years ago

kosich commented 3 years ago

Currently, we are skipping multiple sync emissions. This will wait for all 3 values from a and only then would produce a result:

const a = of(1, 2, 3);
const b = of('🐁');
computed(() => $(a) + $(b)).subscribe(…); // > 3🐁

I think its fine for computed, but it seems to be an issue for our shiny new combined (or whatever name we end up with in #32):

combined(() => $(a) + $(b)).subscribe(…); // > 1🐁 > 2🐁 > 3🐁

Though it's not very clear how to handle this with multiple streams emitting synchronously.

combineLatest ignores sync values from the first stream:

const a$ = of(1,2,3);
const b$ = of('a', 'b', 'c');
const result$ = combineLatest(a$, b$);
combinelatest---rxjs-operator-example---marble-diagram

So, I'm not sure if, what, and how it should be done. Please, share your thoughts!