-
-
Notifications
You must be signed in to change notification settings - Fork 598
Add EventuallyQueue API #1291
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
Add EventuallyQueue API #1291
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1291 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 58 59 +1
Lines 5650 5788 +138
Branches 1273 1299 +26
==========================================
+ Hits 5650 5788 +138
Continue to review full report at Codecov.
|
Looks good, should this be flagged as experimental in the changelog like we do with Parse Server sometimes? |
Since we can’t turn it off it’s not experimental. |
length = await Parse.EventuallyQueue.length(); | ||
assert.strictEqual(length, 0); | ||
|
||
// TODO: Properly handle SingleInstance |
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.
I’m using JSON.stringify to save the object in local storage. When I retrieve it’s no longer a class instance or same reference as the stored object. Is their a way to fix this? In a singleInstance environment like the browser objects with the same id have the same state and values. I can’t pass obj1 into destroy since it didn’t get an objectId from save.
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.
Not sure I understood this correctly, but Object.create
takes the prototype to recreate the instance. Depending on what exactly goes missing, JSON.stringify
only stringifies enumerable, own properties, so sometime you may have to write a custom method to serialize/encode and then deserialize/decode an object.
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.
Stringify calls toJSON() internally. I ran into this issue with the LocalDatastore as well I think.
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.
I have a few questions that I would like feedback on. @mtrezza @davimacedo
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.
Maybe add a chapter about this in the README so people become aware and try this this out? Otherwise LGTM!
Closes: #1230
This is a similar feature to the iOS SDK EventuallyQueue to allow a user to cache objects to be saved later. Inspired by @francimedia repo.
This has a lot of room for improvement, any feedback is appreciated.
Parse.Object
Saves / Deletes this object to the server at some unspecified time in the future, even if Parse is currently inaccessible.
Use this when you may not have a solid network connection, and don't need to know when the save completes.
If there is some problem with the object such that it can't be saved, it will be silently discarded.
Objects saved / deleted with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
next time the app is opened / SDK is initialized.
Advance API
Add Object to Queue
Adding unique hashes to your objects is highly recommended
Send Queue to Parse Server
You can send the queue either right after adding an object or on connect (or other events).
Clear Queue
Polling
This will call sendQueue when a connection to the server is established. Uses the
serverURL
used to initialize sdk