segmentio/deku — pull request #15 by anthonyshort (2014-11-26 06:15:23+00:00)
Title: Single state for component graph

@lancejpollard

This is what I was talking to you about today. The `Scene` can store the state for all the components in it's graph so they're not actually stored on the component itself:

```json
{
"root": { "someKey": "value" },
"root.0": { "open": true }
}
```

This means we can serialize a scene in it's current state (of all the components in the tree) with the props and the state separate. It's not working exactly right yet, this was more just a test. The state on the scene could be an immutable object so updating the state in a component is just updating the cursor.

Here's how it could look using `immstruct` in the `scene`:

```js
this.structure = immstruct({
props: {},
state: {}
});

this.structure.on('next-animation-frame', this.update);
```

Then we just update the cursors and the structure would swap.