Files
soulspace/node_modules/store/plugins/observe.js
2025-03-05 15:16:45 +08:00

20 lines
353 B
JavaScript

var eventsPlugin = require('./events')
module.exports = [eventsPlugin, observePlugin]
function observePlugin() {
return {
observe: observe,
unobserve: unobserve
}
function observe(_, key, callback) {
var subId = this.watch(key, callback)
callback(this.get(key))
return subId
}
function unobserve(_, subId) {
this.unwatch(subId)
}
}