re-rxjs / react-rxjs

React bindings for RxJS
https://react-rxjs.org
MIT License
555 stars 20 forks source link

Debugging a shared stream which doesn't emit a value when expected #319

Open jbhoot opened 1 month ago

jbhoot commented 1 month ago

I've observed a few scenario when this happens:

  1. The stream hasn't been 'subscribed' yet using the associated use hook.
  2. The stream was subscribed with the associated use hook, but the component in which the subscription lived, was unmounted by the time I expected the stream to emit a value. This can be alleviated somewhat with a <Subscribe> component.
  3. Values in the stream passes through a filter operation. For example, I use a parsedValue$$->validValue$$ stream, which filters out Error(e) values, and lets only Ok(v) pass through. Now, often, validValue$$ stream doesn't produce a value when I expect it to. This happens mostly during a formSubmit, where the stream that processes a formSubmit event checks that validValue$$ streams of all of the input value have a latest valid value.

Now, I know all of the 3 points are on me. As in, I need to ensure that the subscription is alive, and that I am responsible for the logic in parsed$$->valid$$.

But examining what went wrong feels like drudgery. Are there ways to make it easy? I am just looking for ideas in case someone has experienced this.

My experience with RxJS is also limited to just react-rxjs. In general, do you recommend rxjs marbles to test and debug rxjs streams? or something else?