aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/observable/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/observable/index.js')
-rw-r--r--app/scripts/lib/observable/index.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/scripts/lib/observable/index.js b/app/scripts/lib/observable/index.js
index d193e5554..1ff112e95 100644
--- a/app/scripts/lib/observable/index.js
+++ b/app/scripts/lib/observable/index.js
@@ -7,22 +7,30 @@ class ObservableStore extends EventEmitter {
this._state = initialState
}
+ // wrapper around internal get
get () {
return this._state
}
-
+
+ // wrapper around internal put
put (newState) {
this._put(newState)
}
+ // subscribe to changes
subscribe (handler) {
this.on('update', handler)
}
+ // unsubscribe to changes
unsubscribe (handler) {
this.removeListener('update', handler)
}
+ //
+ // private
+ //
+
_put (newState) {
this._state = newState
this.emit('update', newState)