You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactoring `useObservable` and `preloadObservable` to be more suspense friendly.
The core idea here is that our "observable" should expose a promise that resolves on first emission (which can be thrown for suspense), a synchronous means of getting the latest value (to pass into `useState`), and a shared subscription for use thereafter (for `useEffect`).
As a matter of optimization they will keep their cache around for only a present amount of time (30 seconds by default) unless they are subscribed to (`useEffect`); in which case the cache will remain until the component is unloaded. This should be enough time to prevent suspense from thrashing.
To encapsulate this behavior this we've implemented our own `Subject`.
Other changes in this PR:
* Ensure that the observable cache has to be keyed very specifically taking into account the firebase app, options, etc.
* Make sure no cache keys overlap on tests & different exports
* We're using more typescript in the tests, build them as part of the main build step since jest wasn't playing nice
* There's still some meh types kicking around here, should take as an AI
* Errors are thrown again until the cache timeout elapses, put down a TODO for now
* `FirebaseAppProvider` now throws if the provided config does not match the existing instance options, rather than simply returning the default
* `FirebaseAppProvider` now takes an `appName` property allowing you to have more than one app
0 commit comments