Comparing version 0.1.3 to 0.1.4
@@ -13,2 +13,3 @@ const connect = require('./connect'); | ||
this.map = {}; | ||
this.times = {}; | ||
this.connect.on('message', (topic, message) => { | ||
@@ -22,5 +23,24 @@ const payload = utils.decodeTopic(topic); | ||
keys.forEach((item) => { | ||
// record the topic last time | ||
this.times[item] = new Date(); | ||
this.map[item](null, payload); | ||
}) | ||
}); | ||
this.connect.on('reconnect', () => { | ||
if (this.apiUrl) { | ||
const timesKeys = Object.keys(this.times); | ||
timesKeys.forEach((item) => { | ||
let where = utils.decodeTopic(item); | ||
const keys = Object.keys(where); | ||
keys.forEach((key) => { | ||
if (where[key] === '+' || where[key] === '#') { | ||
delete where[key]; | ||
} | ||
}); | ||
where = _.assign(where, {updatedAt: {gt: this.times[item]}}); | ||
this.map[item] && request.reassembly(this.apiUrl, where, this.map[item]); | ||
}) | ||
} | ||
}); | ||
} | ||
@@ -27,0 +47,0 @@ |
{ | ||
"name": "pubsubr", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "pub and sub to loopback components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27319
602