lhorie/mithril.js — pull request #54 by thatsmydoing (2014-04-19 02:44:58+00:00)
Title: Allow m.prop to be JSON.stringify-ed

The main use case for this is when storing an object containing props such as

var model = {
name: m.prop(""),
age: m.prop("")
}

And then passing that off to `m.request`. Normally, it would be converted to an empty object because functions don't get serialized. Adding a `toJSON` method allows us to override that and return the actual value.

I do think it's inefficient to assign the function every time, but I can't think of a better way to do it.