1,007
edits
Line 52: | Line 52: | ||
== Writing a Store class == | == Writing a Store class == | ||
=== Create / Update / Remove === | |||
The next three methods are called by the sync algorithm when it determines that the state of the local application needs to be changed to keep it up-to-date with the user's remote activities. The sync algorithm will call your Store object with a record to be created, updated, or removed, and it is your Store object's responsibility to apply this change to the local application using whatever methods are neccessary. | |||
<tt>create(record)</tt> | |||
:Not to be confused with <tt>createRecord()</tt>, this method (which should probably be renamed for clarity soon) tells your Store to create a new item in the local application, based on the data in record. (So for example, <tt>BookmarkStore.create()</tt> adds a new bookmark to the Firefox profile). | |||
<tt>update(record)</tt> | |||
:The argument is a record which has been remotely modified; your Store should locate the matching local item (presumably using the GUID, which is available in record.id) and update it to the new values provided in <tt>record</tt>. | |||
<tt>remove(record)</tt> | |||
:The argument is a record which has been remotely deleted; your Store should locate the matching local item and delete it. | |||
=== Example Store class skeleton === | === Example Store class skeleton === |
edits