-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save hook is on the atom's `env` and accepts arguments: `(value, payload)`. Calling the save hook rerenders the atom. Example: ``` let atom = { name: 'my-atom', type: 'dom', render({env, value, payload}) { let el = document.createElement('button'); let clicks = payload.clicks || 0; el.appendChild(document.createTextNode('Clicks: ' + clicks)); el.onclick = () => { payload.clicks = payload.clicks || 0; payload.clicks++; env.save(value, payload); }; return el; } }; ``` Also: improve postAbstract buildFromText to accept data for an atom, i.e. "abc@(...jsondata...)", e.g.: ``` buildFromText('abc@("name": "my-atom", "value": "bob", "payload": {"foo": "bar"})def'); // -> "abc" + atom with name "my-atom", value "bob", payload {foo: 'bar'} + "def" ``` Fixes #399
- Loading branch information
Showing
5 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters