mobx-decorated-models
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -79,6 +79,6 @@ (function (global, factory) { | ||
serializer: function serializer(obj) { | ||
return obj.toJS(); | ||
return obj; | ||
}, | ||
deserializer: function deserializer(json, cb) { | ||
cb(null, mobx.observable.map(json)); | ||
cb(null, json); | ||
} | ||
@@ -301,3 +301,5 @@ }; | ||
if (inverseOf) { | ||
attrs[inverseOf + '_association_name'] = parentModelProp; | ||
if (parentModelProp) { | ||
attrs[inverseOf + '_association_name'] = parentModelProp; | ||
} | ||
attrs[inverseOf] = parentModel; | ||
@@ -348,3 +350,3 @@ } | ||
object: function object$$1() { | ||
return mobx.observable.map({}); | ||
return mobx.observable.object({}); | ||
}, | ||
@@ -351,0 +353,0 @@ array: buildCollection |
@@ -76,6 +76,6 @@ import { createModelSchema, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr'; | ||
serializer: function serializer(obj) { | ||
return obj.toJS(); | ||
return obj; | ||
}, | ||
deserializer: function deserializer(json, cb) { | ||
cb(null, observable.map(json)); | ||
cb(null, json); | ||
} | ||
@@ -298,3 +298,5 @@ }; | ||
if (inverseOf) { | ||
attrs[inverseOf + '_association_name'] = parentModelProp; | ||
if (parentModelProp) { | ||
attrs[inverseOf + '_association_name'] = parentModelProp; | ||
} | ||
attrs[inverseOf] = parentModel; | ||
@@ -345,3 +347,3 @@ } | ||
object: function object$$1() { | ||
return observable.map({}); | ||
return observable.object({}); | ||
}, | ||
@@ -348,0 +350,0 @@ array: buildCollection |
@@ -10,3 +10,3 @@ import { | ||
import { registerModel, findModel } from './model-lookup'; | ||
import { isSerializable, markNonserializable } from './serializable' | ||
import { isSerializable, markNonserializable } from './serializable'; | ||
import getSchema from './schema'; | ||
@@ -27,4 +27,4 @@ | ||
return { | ||
serializer(obj) { return obj.toJS(); }, | ||
deserializer(json, cb) { cb(null, observable.map(json)); }, | ||
serializer(obj) { return obj; }, | ||
deserializer(json, cb) { cb(null, json); }, | ||
}; | ||
@@ -31,0 +31,0 @@ } |
@@ -23,3 +23,5 @@ import { | ||
if (inverseOf) { | ||
attrs[`${inverseOf}_association_name`] = parentModelProp; | ||
if (parentModelProp) { | ||
attrs[`${inverseOf}_association_name`] = parentModelProp; | ||
} | ||
attrs[inverseOf] = parentModel; | ||
@@ -32,6 +34,4 @@ } | ||
function buildInterceptor( | ||
{ modelClass, className, defaults: defaultAttributes, inverseOf }, | ||
parentModel, parentModelProp) | ||
{ | ||
function buildInterceptor({ modelClass, className, defaults: defaultAttributes, inverseOf }, | ||
parentModel, parentModelProp) { | ||
return (change) => { | ||
@@ -69,3 +69,3 @@ if (!change.newValue) { | ||
const Initializers = { | ||
object: () => observable.map({}), | ||
object: () => observable.object({}), | ||
array: buildCollection, | ||
@@ -72,0 +72,0 @@ }; |
{ | ||
"name": "mobx-decorated-models", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Decorators to make using Mobx for model type structures easier", | ||
@@ -5,0 +5,0 @@ "main": "dist/build.full.js", |
@@ -57,3 +57,3 @@ import { Box, Container, Ship } from './test-models'; | ||
}); | ||
expect(ship.box.container_association_name).toEqual('box') | ||
expect(ship.box.container_association_name).toEqual('box'); | ||
}); | ||
@@ -86,3 +86,3 @@ | ||
}); | ||
expect(box.metadata.toJS()).toEqual({ barcode: 'Z12', color: 'black' }); | ||
expect(box.metadata).toEqual({ barcode: 'Z12', color: 'black' }); | ||
expect(box.serialize()).toEqual({ | ||
@@ -89,0 +89,0 @@ container: undefined, depth: 1, height: 1, id: undefined, width: 3, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186989
1224