Last active
December 21, 2015 14:29
-
-
Save janl/6320157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/account_manager.js b/lib/account_manager.js | |
index a46aa93..c018b4b 100644 | |
--- a/lib/account_manager.js | |
+++ b/lib/account_manager.js | |
@@ -17,7 +17,25 @@ exports.start = function (manager, callback) { | |
var feed = couchr.changes(user_db, {include_docs: true}); | |
feed.on('change', function (change) { | |
- am.emit('change', change); | |
+ console.log('handle account change: %j', change); | |
+ var doc = JSON.parse(JSON.stringify(change.doc)); | |
+ am.emit('change', doc); | |
+ console.log('emitted `change`'); | |
+ if (!doc.hasOwnProperty('$processedAt')) { | |
+ am.emit('add', doc); | |
+ console.log('emitted `add`'); | |
+ } | |
+ if (doc.type) { | |
+ var type = doc.type; | |
+ am.emit('change:' + type, doc); | |
+ console.log('emitted `change:' + type + '`'); | |
+ | |
+ if (!doc.hasOwnProperty('$processedAt')) { | |
+ am.emit('add:' + type, doc); | |
+ console.log('emitted `add:' + type + '`'); | |
+ } | |
+ } | |
+ console.log('done handling account change %j', change); | |
}); | |
am.stop = function (callback) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment