-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App state caching: improvements #313
Conversation
ca42676
to
b451ece
Compare
// Ensure a promise is returned even if the reducer returns an array or throws | ||
new Promise((resolve) => resolve(reducer(state, event))) | ||
).pipe( | ||
catchError((err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I wasn't aware of this operator
Didn't see this and already implemented it in #297
Sensible
I agree. How do you envision the passing of state between script to app? |
Good question! Been thinking a little bit about how this would work, since it'd also be required for the "triggers". This state "trigger" could be implemented directly as a The ephemeral "trigger" would be exactly the same as above, but just using a normal |
* add handler for past events - emit a single emission for past events - add ability to fetch arbitrary cache keys * Make caching happen 🌶🎲🥊 * Remove unneeded imports and add comments * Use the share operator to prevent duplicate calls * Remove unnecessary import * Add accounts trigger WIP * Add comment about Promise.resolve * api: update store signature to an options object and update docs * Update test name * Catch errors from app reducer Fixes #262 * Add handler for external past events * Cache external contract events * Update docs and remove events param * Disable store test * Remove unneeded import * Add initializationBlock option for external contracts * Consistent spelling As much as it's counter intuitive for me to use z consistency is what matterz * tests: improve core/proxy tests * cosmetic(api): improve comments * Update packages/aragon-api/src/index.js Co-Authored-By: Brett Sun <[email protected]> * Store init with cached state * Clarify return value of reducer * Clamp block number for local chains In local chains this can yield an invalid negative value * Ensure the pasteStates observable is fully hot * Instantiate currentEvents in the block its used in * Emit state and cache once pastEvents have finished processing processed * fixup! Clamp block number for local chains * Ensure consistency between getCurrentEvents and getPastEvents * Separate state cache from actual runtime state * Remove unncessary import * Emit sync events * Use to for consistency in sync event * Simplify event reduction to a single observable chain * Use web3 instead of the proxy class in external handlers * Remove unnecessary import * Allow passing all web3 options to external pastEvents * Change to strings so the statuses can be used in frontend - symbols can't be serialised by postMessage * Stop setting cache from creating new subscriptions - use forkJoin instead of combineLatest * Use single cache key for block and cached state * fixup! Use single cache key for block and cached state * Move accounts observable closer to usage * App state caching: improvements (#313) * App state caching: improvements++ (#317) * api: commit initialized store state immediately to avoid showing non-cached state from previous runs * api: fetch current blocks from block after cached height * api: emit when cache has been committed, and commit cache operations one by one in store * api: use throttleTime() instead of sampleTime() for throttling * api: update docs for change to cache() * wrapper: use pastEvents() strategy for caching * Upgrade rxjs to avoid endWith() bug * @aragon/api, @aragon/api-react: v2.0.0-beta.1 * @aragon/wrapper: 5.0.0-rc.8 * api-react: add prepublishOnly script * Export single events constant and use strings * Release @aragon/api 2.0.0-beta.2 * @aragon/wrapper: 5.0.0-rc.10 * api: only log debug messages on development environment (#320) * @aragon/api: v2.0.0-beta.3
A couple of improvements to #297.
this.accounts()
directly without worrying about the first emission being lostnew Promise()
also catches the case wherereducer()
throws synchronously, and thecatchError()
operator allows us to log and re-throw the errorstore()
stream for now, rather than silently returning the previousstate
and continuing the reducingstate
to be in-memory, since now we're effectively using double the storage (state
andcache
representations of the app's reduced state)