-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json.mapOf()? #5
Comments
I'm using this const jsonObservableMap = (mapData) => {
// extends observable map, so json-mobx know how to serialize it
const map = observable.map(mapData)
Object.defineProperties(map, {
json: {
get: () => map.toJS(),
set: data => map.replace(data)
}
})
return map
} Like this class SomeClass {
@json @observable attrs = jsonObservableMap()
} |
That looks just about perfect to me. |
@danielearwicker would love to have this in the json-mobx so npm install just work. |
I could look at this or accept PRs. I would need it to be typescript aware though. Also note that the built-in array support allows for: json.arrayOf(MyClass) where So it would be good to have: json.mapOf(MyClass) which would define a map of |
Is there a equivalent for
json.arrayOf
but for observable maps instead of arrays?The text was updated successfully, but these errors were encountered: