clean_sync.server library
A library for data subscription and synchronization in single page applications.
Properties
const dummyCache #
const dummyCache = const DummyCache()
final Function historyCollectionName #
final Function historyCollectionName =
(collectionName) => "__clean_${collectionName}_history"
final PUBLISHER #
final PUBLISHER = new Publisher()
var watchID #
var watchID = 0
Functions
MongoProvider mpClone(MongoProvider source) #
MongoProvider mpClone(MongoProvider source){
MongoProvider m = new MongoProvider(source.collection, source._collectionHistory,
source._lock, source.cache);
m._selectorList = new List.from(source._selectorList);
m._sortParams = new Map.from(source._sortParams);
m._limit = source._limit;
m._fields = new List.from(source._fields);
m._excludeFields = new List.from(source._excludeFields);
return m;
}
List addFieldIfNotEmpty(List fields, String field) #
List addFieldIfNotEmpty(List fields, String field){
if (fields.isNotEmpty) {
var res = new List.from(fields)..add(field);
return res;
} else {
return fields;
}
}
Map slice(Map map, List keys) #
TODO: this function should be tidied up to some utilities class Creates a new Map out of the given map preserving only keys specified in [keys] [map] is the Map to be sliced keys is a list of keys to be preserved
Map slice(Map map, List keys) {
Map result = {};
keys.forEach((key) {
if (map.containsKey(key)) {
result[key] = map[key];
}
});
return result;
}
Future handleSyncRequest(request) #
Future handleSyncRequest(request) {
return PUBLISHER.handleSyncRequest(request);
}
bool isPublished(String collection) #
bool isPublished(String collection) {
return PUBLISHER.isPublished(collection);
}
void publish(String c, DataGenerator dg, {beforeRequest: null}) #
void publish(String c, DataGenerator dg, {beforeRequest: null}) {
PUBLISHER.publish(c, dg, beforeRequest: beforeRequest);
}
dynamic logElapsedTime(watchID) #
logElapsedTime(watchID) {
var watch = watches[watchID][0];
var identifier = watches[watchID][1];
profilingLogger.info('$watchID Processing request ($identifier) currently elapsed '
'${watch.elapsed}.');
}
dynamic stopWatch(watchID) #
stopWatch(watchID) {
var watch = watches[watchID][0];
var identifier = watches[watchID][1];
profilingLogger.info('$watchID Processing request ($identifier) took ${watch.elapsed}.');
watch.stop();
watches.remove(watchID);
}