@nxtedition/agent
Advanced tools
Comparing version 1.0.6 to 1.0.7
33
index.js
@@ -12,2 +12,13 @@ const objectHash = require('object-hash') | ||
const providers = new Map() | ||
setInterval(() => { | ||
for (const [ key, provider ] of providers) { | ||
if (provider.refs === 0) { | ||
provider.unsubscribe() | ||
providers.delete(key) | ||
} | ||
} | ||
}, 60000) | ||
module.exports = { | ||
@@ -20,5 +31,21 @@ observe (query, prop) { | ||
.using( | ||
() => ({ | ||
unsubscribe: ds.record.provide(`${hash}:agent.query`, () => Observable.of(query)) | ||
}), | ||
() => { | ||
let provider = providers.get(hash) | ||
if (!provider) { | ||
provider = { | ||
unsubscribe: ds.record.provide(`${hash}:agent.query`, () => Observable.of(query)), | ||
refs: 0 | ||
} | ||
providers.set(hash, provider) | ||
} | ||
provider.refs += 1 | ||
return { | ||
unsubscribe: () => { | ||
provider.refs -= 1 | ||
} | ||
} | ||
}, | ||
() => ds.record.observe(`${hash}:agent${prop ? `.${prop}` : ``}`) | ||
@@ -25,0 +52,0 @@ ) |
{ | ||
"name": "@nxtedition/agent", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "Robert Nagy <robert.nagy@boffins.se>", |
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
3415
58