Skip to content

Commit 4c1aa9a

Browse files
authored
Add js docs for EventuallyQueue API (#938)
1 parent ef251ea commit 4c1aa9a

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

_includes/js/objects.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ teamMember.save(null, { cascadeSave: false });
207207

208208
### Saving Objects Offline
209209

210-
Most save functions execute immediately, and inform your app when the save is complete. If you don’t need to know when the save has finished, you can use `saveEventually` instead. The advantage is that if the user currently doesn’t have a network connection, `saveEventually` will store the update on the device until a network connection is re-established. If your app is closed before the connection is back, Parse will try again the next time the app is opened. All calls to `saveEventually` (and `destroyEventually`) are executed in the order they are called, so it is safe to call `saveEventually` on an object multiple times. If you have the local datastore enabled, then any object you saveEventually will be pinned as long as that save is in progress. That makes it easy to retrieve your local changes while waiting for the network to be available. `Parse.enableLocalDatastore()` must be called to use this feature.
210+
Most save functions execute immediately, and inform your app when the save is complete. If you don’t need to know when the save has finished, you can use `saveEventually` instead. The advantage is that if the user currently doesn’t have a network connection, `saveEventually` will store the update on the device until a network connection is re-established. If your app is closed before the connection is back, Parse will try again the next time the app is opened. All calls to `saveEventually` (and `destroyEventually`) are executed in the order they are called, so it is safe to call `saveEventually` on an object multiple times. If you have the local datastore enabled, then any object you saveEventually will be pinned as long as that save is in progress. That makes it easy to retrieve your local changes while waiting for the network to be available. If an error occurs while saving or deleting an object the data will be lost. `Parse.enableLocalDatastore()` must be called to use this feature.
211211

212212
```javascript
213213
const TeamMember = Parse.Object.extend("TeamMember");
@@ -218,6 +218,38 @@ teamMember.set('ownerAccount', ownerAccount);
218218
await teamMember.saveEventually();
219219
```
220220

221+
### Saving Objects Offline Advanced API
222+
223+
The SDK provides utility functions to queue objects that will be saved to the server at a later date with `Parse.EventuallyQueue`. See <a href="https://parseplatform.org/Parse-SDK-JS/api/release/Parse.EventuallyQueue.html">EventuallyQueue API</a> for full documentation.
224+
225+
#### Add Object to Queue
226+
Adding unique hashes to your objects is highly recommended
227+
228+
```javascript
229+
const object = new Parse.Object('TestObject');
230+
object.save({ hash: 'unique' });
231+
232+
await Parse.EventuallyQueue.save(object, options);
233+
await Parse.EventuallyQueue.destroy(object, options);
234+
```
235+
236+
#### Send Queue to Parse Server
237+
```javascript
238+
await Parse.EventuallyQueue.sendQueue();
239+
```
240+
You can send the queue either right after adding an object or on connect (or other events).
241+
242+
#### Clear Queue
243+
```javascript
244+
await Parse.EventuallyQueue.clear();
245+
```
246+
247+
#### Polling
248+
This will call sendQueue when a connection to the server is established. Uses the `serverURL` used to initialize sdk
249+
```javascript
250+
Parse.EventuallyQueue.poll();
251+
```
252+
221253
### Cloud Code context
222254

223255
*Requires Parse Server 4.3.0+*

0 commit comments

Comments
 (0)