diff options
author | kumavis <aaron@kumavis.me> | 2017-01-12 14:47:56 +0800 |
---|---|---|
committer | kumavis <aaron@kumavis.me> | 2017-01-12 14:47:56 +0800 |
commit | 3bc996878b467e1fa5fd63656bd465377daa137d (patch) | |
tree | 9c1661af778b58cd6d83c7d5fb5727f7a61b6dd9 /app/scripts/lib/observable/util | |
parent | 2019c02fc0fc33d4bd98416654370250d7aa0ca6 (diff) | |
download | tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.gz tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.tar.zst tangerine-wallet-browser-3bc996878b467e1fa5fd63656bd465377daa137d.zip |
background - move pojo migrator to outside of metamask controller
Diffstat (limited to 'app/scripts/lib/observable/util')
-rw-r--r-- | app/scripts/lib/observable/util/sync.js | 24 | ||||
-rw-r--r-- | app/scripts/lib/observable/util/transform.js | 13 |
2 files changed, 24 insertions, 13 deletions
diff --git a/app/scripts/lib/observable/util/sync.js b/app/scripts/lib/observable/util/sync.js new file mode 100644 index 000000000..c61feb02e --- /dev/null +++ b/app/scripts/lib/observable/util/sync.js @@ -0,0 +1,24 @@ + +// +// synchronizeStore(inStore, outStore, stateTransform) +// +// keeps outStore synchronized with inStore, via an optional stateTransform +// + +module.exports = synchronizeStore + + +function synchronizeStore(inStore, outStore, stateTransform) { + stateTransform = stateTransform || transformNoop + const initState = stateTransform(inStore.get()) + outStore.put(initState) + inStore.subscribe((inState) => { + const outState = stateTransform(inState) + outStore.put(outState) + }) + return outStore +} + +function transformNoop(state) { + return state +}
\ No newline at end of file diff --git a/app/scripts/lib/observable/util/transform.js b/app/scripts/lib/observable/util/transform.js deleted file mode 100644 index 87946f402..000000000 --- a/app/scripts/lib/observable/util/transform.js +++ /dev/null @@ -1,13 +0,0 @@ - -module.exports = transformStore - - -function transformStore(inStore, outStore, stateTransform) { - const initState = stateTransform(inStore.get()) - outStore.put(initState) - inStore.subscribe((inState) => { - const outState = stateTransform(inState) - outStore.put(outState) - }) - return outStore -}
\ No newline at end of file |