pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.36k stars 1.04k forks source link

RxState changes #6459

Open kilbot opened 23 hours ago

kilbot commented 23 hours ago

Did something change with RxState recently?

I used to be able to do useObservableEagerState(RxState.property$), but suddenly it's causing infinite renders everywhere. To fix it I had to change usage to useObservableState(RxState.property$.pipe(skip(1)), RxState.property).

It's possible it has something to do with this note from observable-hooks:

If the observable is cold and with side effects they will be performed at least twice! It is only safe if the observable is hot or pure.

kilbot commented 23 hours ago

I just rolled back to 15.33.0 and the problem is fixed.

My knowledge of rxjs is not great, but is it possible to go back to the previous way of emitting values? This would keep it consistent with RxDocument, eg: useObservableEagerState(RxDocument.property$) still works fine.

pubkey commented 8 hours ago

Yes there was a change to fix a bug that let the tests fail randomly: https://github.com/pubkey/rxdb/commit/aba371c7d0c1ba4f8f9aa46a8321963d17450b20 Please make a test case if there is something not working for you.

kilbot commented 7 hours ago

Here is a codesandbox illustrating the problem: https://codesandbox.io/p/sandbox/6mdyks

I will take a look at the code when I get a chance to put this in something that can pass/fail a test.