aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/observable/util/transform.js
blob: 87946f402aeeb9d33b9815701d734489b4a187c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13

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
}