aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/remote-store.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-22 04:18:32 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-22 04:18:32 +0800
commita08c3bc01b11fbd0e3a243359befbe9fc909edf4 (patch)
treeb79b7324139945c429ca4b6c74715d8040fdf4e1 /app/scripts/lib/remote-store.js
parentf7f8f8b1c50be39db22a7b10c6c6db007fe590aa (diff)
downloadtangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.gz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.bz2
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.lz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.xz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.zst
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.zip
Auto linted
Diffstat (limited to 'app/scripts/lib/remote-store.js')
-rw-r--r--app/scripts/lib/remote-store.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/app/scripts/lib/remote-store.js b/app/scripts/lib/remote-store.js
index 2dbdde811..fbfab7bad 100644
--- a/app/scripts/lib/remote-store.js
+++ b/app/scripts/lib/remote-store.js
@@ -6,32 +6,32 @@ module.exports = {
RemoteStore: RemoteStore,
}
-function BaseStore(initState){
+function BaseStore (initState) {
this._state = initState || {}
this._subs = []
}
-BaseStore.prototype.set = function(key, value){
+BaseStore.prototype.set = function (key, value) {
throw Error('Not implemented.')
}
-BaseStore.prototype.get = function(key){
+BaseStore.prototype.get = function (key) {
return this._state[key]
}
-BaseStore.prototype.subscribe = function(fn){
+BaseStore.prototype.subscribe = function (fn) {
this._subs.push(fn)
var unsubscribe = this.unsubscribe.bind(this, fn)
return unsubscribe
}
-BaseStore.prototype.unsubscribe = function(fn){
+BaseStore.prototype.unsubscribe = function (fn) {
var index = this._subs.indexOf(fn)
if (index !== -1) this._subs.splice(index, 1)
}
-BaseStore.prototype._emitUpdates = function(state){
- this._subs.forEach(function(handler){
+BaseStore.prototype._emitUpdates = function (state) {
+ this._subs.forEach(function (handler) {
handler(state)
})
}
@@ -41,16 +41,16 @@ BaseStore.prototype._emitUpdates = function(state){
//
inherits(HostStore, BaseStore)
-function HostStore(initState, opts){
+function HostStore (initState, opts) {
BaseStore.call(this, initState)
}
-HostStore.prototype.set = function(key, value){
+HostStore.prototype.set = function (key, value) {
this._state[key] = value
process.nextTick(this._emitUpdates.bind(this, this._state))
}
-HostStore.prototype.createStream = function(){
+HostStore.prototype.createStream = function () {
var dnode = Dnode({
// update: this._didUpdate.bind(this),
})
@@ -58,8 +58,8 @@ HostStore.prototype.createStream = function(){
return dnode
}
-HostStore.prototype._didConnect = function(remote){
- this.subscribe(function(state){
+HostStore.prototype._didConnect = function (remote) {
+ this.subscribe(function (state) {
remote.update(state)
})
remote.update(this._state)
@@ -70,16 +70,16 @@ HostStore.prototype._didConnect = function(remote){
//
inherits(RemoteStore, BaseStore)
-function RemoteStore(initState, opts){
+function RemoteStore (initState, opts) {
BaseStore.call(this, initState)
this._remote = null
}
-RemoteStore.prototype.set = function(key, value){
+RemoteStore.prototype.set = function (key, value) {
this._remote.set(key, value)
}
-RemoteStore.prototype.createStream = function(){
+RemoteStore.prototype.createStream = function () {
var dnode = Dnode({
update: this._didUpdate.bind(this),
})
@@ -87,11 +87,11 @@ RemoteStore.prototype.createStream = function(){
return dnode
}
-RemoteStore.prototype._didConnect = function(remote){
+RemoteStore.prototype._didConnect = function (remote) {
this._remote = remote
}
-RemoteStore.prototype._didUpdate = function(state){
+RemoteStore.prototype._didUpdate = function (state) {
this._state = state
this._emitUpdates(state)
}