-
Notifications
You must be signed in to change notification settings - Fork 3
Samuel edited this page Nov 4, 2013
·
4 revisions
typedef DataProvider DataGenerator(Map args);
class Publisher {
publish(String collection, DataGenerator callback);
getData(String collection, Map args);
getDiff(String collection, Map args, num version);
}DataProvider {
List<Map> data;
diffFromVersion(version) // diff in some reasonable format
}
MongoProvider implements DataProvider {};Subscriber class generates synchronization requests to server and handles opening and closing of subscription.
class Subscriber {
Subscriber(Server server);
Subscription subscribe(String collection, [Map args]);
}Subscription class gathers information about client side changes in data and provide synchronization with server. It listens to changes in collection data (only on remove and add events) and to changes in all Data objects present at the time of last succesful synchronization with server.
class Subscription {
num _version;
_changeSet;
DataCollection data;
close();
Stream onClose();
}Data and DataCollection should provide a way to add/change data comming from Server without notifying sync routine.
This could be implemented by providing methods add, remove, change with additional optional parameter {fromSource} and accepting optional sourceNotify callback in constructor for sync notification.