Replies: 2 comments 2 replies
-
The key to this is saving the cursors returned by the server upon updates. You can use that cursor to initialize the proxy upon a restart, it will then only fetch changes from the server instead of the entire value. To monitor the cursor use: proxy.on('cursor', cursor => {
// Save cursor somewhere (local state db / localStorage etc)
localStateDb.ref('mycursors/someproxy').set(cursor);
}); To inititialize the proxy upon startup: // Get stored cursor from local state db / localStorage etc
const cursor = (await localStateDb.ref('mycursors/someproxy').get()).val();
// Initialize proxy with cursor and default value
const defaultValue = {};
const proxy = await db.ref('someuser/somecollection').proxy({ cursor, defaultValue }); |
Beta Was this translation helpful? Give feedback.
2 replies
-
The only place you should enable transaction logging is in your server config. Make sure you are using the latest packages, client v1.16.0+ and server v1.11.0+ should properly handle cursor updates! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have cache enabled on the client browser, and extensively using live data proxies. I also have transactions enabled (i believe). I initialize all the proxies to various nodes on login, and use those proxies throughout the session to communicate with the db. So basically initialize all the data up front for faster processing later. Generally works well.
Im trying to make this more efficient as users and datasets gets bigger and the initialization is taking longer and longer. The pain point i have now is on initialization of the proxies, it appears to read through the entire tree of the nodes, rather than just a diff. A lot of the data is user specific, so it shouldn't change between the user's cache. Between the transitions, cache and proxies, is there some magic to only initialize the diff, and generally make the initialization process more efficient?
Beta Was this translation helpful? Give feedback.
All reactions