-
Notifications
You must be signed in to change notification settings - Fork 3
/
neo4j_watcher.js
51 lines (47 loc) · 1.29 KB
/
neo4j_watcher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var path = Npm.require('path');
var Future = Npm.require(path.join('fibers', 'future'));
Neo4jWatcher = function (url) {
var self = this;
self._url = url;
self._watchConnection = null;
self._stopped = false;
self._readyFuture = new Future();
self._listeners = [];
self._start();
};
_.extend(Neo4jWatcher.prototype, {
stop: function () {
var self = this;
if (self._stopped)
return;
self._stopped = true;
// XXX should close connections too
},
addListener: function (listener) {
var self = this;
self._listeners.push(listener);
},
removeListener: function (listener) {
var self = this;
self._listeners = _.without(self._listeners, listener);
},
_start: function () {
var self = this;
self._watchConnection = new Neo4jClient(self._url);
var listener = function (key, message) {
_.each(self._listeners, function (listener) {
listener(key, message);
});
};
/*
self._watchConnection.subscribeKeyspaceEvents(function (err, results) {
if (err != null) {
Meteor._debug("Error subscribing to neo4j changes: " + JSON.stringify(err));
self._readyFuture.throw(new Error("Error subscribing to redis changes"));
} else {
self._readyFuture.return();
}
}, listener);
*/
}
});