CloudServices/Sync/FxSync/Developer/ClientAPI: Difference between revisions

Jump to navigation Jump to search
→‎Writing an Engine class: SyncEngine should be imported via main.js rather than directly. And exporting your engine is unnecessary.
(→‎The Score: Trackers should not change the private _score property)
(→‎Writing an Engine class: SyncEngine should be imported via main.js rather than directly. And exporting your engine is unnecessary.)
Line 252: Line 252:


  function FooEngine() {
  function FooEngine() {
   SyncEngine.call(this, "Foo");
   Weave.SyncEngine.call(this, "Foo");
  }
  }
  FooEngine.prototype = {
  FooEngine.prototype = {
   __proto__: SyncEngine.prototype,
   __proto__: Weave.SyncEngine.prototype,
   _recordObj: FooRecord,
   _recordObj: FooRecord,
   _storeObj: FooStore,
   _storeObj: FooStore,
Line 263: Line 263:
As you can see, there isn't actually any new code here at all; the prototype simply defines some metadata such as the Store and Tracker classes to use, and the human-readable name that will be used in the log files to identify errors and status messages coming from this engine.
As you can see, there isn't actually any new code here at all; the prototype simply defines some metadata such as the Store and Tracker classes to use, and the human-readable name that will be used in the log files to identify errors and status messages coming from this engine.


(Don't forget that you'll need to import SyncEngine and export FooEngine.  So the top of your file should include:)
(Don't forget that you'll need to import Weave.  So the top of your file should include:)


const EXPORTED_SYMBOLS = ["FooEngine", /* ... etc... */ ];
  const Cu = Components.utils;
  const Cu = Components.utils;
  // etc...
  // etc...
  Cu.import("resource://services-sync/engines.js");
  Cu.import("resource://services-sync/main.js");


== Installing your classes into Sync ==
== Installing your classes into Sync ==

Navigation menu