mirror of
https://github.com/zhigang1992/reactfire.git
synced 2026-06-09 20:27:12 +08:00
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
18 lines
247 B
Plaintext
18 lines
247 B
Plaintext
.DS_Store
|
|
npm-debug.log
|
|
|
|
dist/
|
|
node_modules/
|
|
|
|
.vscode/*
|
|
|
|
|
|
|
|
reactfire/docs/reactfire-metadata.json
|
|
reactfire/firestore-debug.log
|
|
reactfire/firebase-debug.log
|
|
reactfire/pub/**
|
|
pub
|
|
yarn-error.log
|
|
reactfire/database-debug.log
|
|
reactfire/reactfire-*.tgz |