Getting In Sync
The Sync API
Last week saw the first Alpha release of the AeroGear Sync Server.
Our Sync Server is an implementation of the Differential Synchronization Algorithm by Neil Fraser
The Main new feature of this JS release is the Sync Server Client SDK.
The SDK has 2 flavors of engines to interact with the Sync Server:
JSON Patch and Diff Match Patch
In our JS cookbook, We have created an Example that uses the JSON Patch Engine
Lets see an example:
syncClient = AeroGear.DiffSyncClient({
serverUrl: 'ws://localhost:7777/sync',
onopen: function () {},
onsync: function () {}
});
Here we call the DiffSyncClient
constructor with some options. You will notice that we are using Websockets as our transfer protocol.
By default, the JSON Patch engine will be used.
Then to add a “Document” which is really just an object, we can call the addDocument
method
syncClient.addDocument(someObject);
If we need to get that document back out of the engine, we can use the fetch
method:
syncClient.fetch(someDocumentId);
And when we make changes to our document, we call the sync
method:
syncClient.sync(someChangedObject);
Each of the above methods will result in the onsync
callback to be called
We define a specific format for the document:
var document = {
id: ...,
clientId: ...,
content: { ... }
};
This New API is currently marked as experimental, so we encourage everyone to try it out and let us know what works and what doesn’t.
Polyfill Removal
Prior to this release, we were embedding the ES6 Promise Polyfill.
Now that almost all Major browers are supporting Promises natively we’ve decided to not include it.
If you still need to support a browser without native support, you will need to include the polyfill
Deprecations and Removals
Authz
This release we removed the Authz module completely from the library. This module was marked as experimental and it didn’t really add much value anyway.
AeroGear.ajax
The AeroGear.ajax module, which was just an internal thing, has also been removed. There was only one place it was being used, the Unified Push Client SDK, so it didn’t make sense anymore to have this as a standalone thing.
Notifier
We also started the Deprecation process for the Notifier Module.
The abstraction that notifier provides no longer makes sense. The code will eventually be removed in a Major release.
Get the Code
The usual spots still apply.
Source Code:
https://github.com/aerogear/aerogear-js/releases/tag/2.1.0
Bower:
bower install aerogear
There are some “pre-built” components that can be installed with bower
from the AeroGear Components repo
Release Notes - AeroGear JavaScript - Version 2.1.0
Bug
- [AGJS-289] - Diff Sync Example doesn't build due to Ember CLI error
Enhancement
- [AGJS-265] - Remove base64 polyfill
- [AGJS-266] - Add all tests to the Qunit Test Suite index Page
- [AGJS-267] - Update sock.js cdn for examples that use it
Epic
- [AGJS-260] - Implement JavaScript Client Sync Engine
Feature Request
- [AGJS-70] - Remove jQuery requirement
- [AGJS-124] - Create a Diff Sync Client
- [AGJS-268] - Move Sync Server js-client example to cookbook
- [AGJS-279] - Merge AeroGear.ajax into UnifiesPush Client
- [AGJS-281] - Deprecate Notifier
- [AGJS-287] - Update Sync Lib to not use "Array Pattern"
Task
- [AGJS-257] - Remove ES6 polyfil
- [AGJS-269] - Deprecate Authorization module
- [AGJS-270] - Deprecate Google Drive cookbook example
- [AGJS-275] - JavaScript Client Engine should support JSON Patch
- [AGJS-280] - Remove Authz and AeroGear.ajax related stuff from builder