arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

Nested updates #38

Closed scottcorgan closed 9 years ago

scottcorgan commented 9 years ago

Can't find much in the docs on updated nested data. Would it be something like this?

let store = new Freezer({
  a: {
    b: {
      d: 1
    },
    c: {
      e: 2
    }
  }
});

let data = store.get();
let newData = data.set({
  a: {
    b: {
      d: 3
    }
  }
});

console.log(newData.a.b.d) // 3

I tried this and it returned an object without the updated keys.

scottcorgan commented 9 years ago

nm, figured it out. Just need to call store.get() again.