make getter-setters json-serializable

This commit is contained in:
Leo Horie 2014-04-19 22:22:02 -04:00
parent 0aba8aa4bd
commit cb6994dd93
9 changed files with 49 additions and 14 deletions

View file

@ -1,6 +1,6 @@
## m.prop
This is a getter-setter factory utility. It returns a function that stores information
This is a getter-setter factory utility. It returns a function that stores information.
---
@ -56,6 +56,19 @@ m.request({method: "GET", url: "/users"})
---
### Serializing getter-setters
Getter-setters are JSON-serializable:
```javascript
var data = {foo: m.prop("bar")};
JSON.stringify(data); // '{"foo": "bar"}'
```
This allows getter-setters to be passed directly as parameters to [`m.request`](mithril.request.md), for example.
---
### Signature
[How to read signatures](how-to-read-signatures.md)