mobx-decorated-models
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -121,4 +121,7 @@ (function (global, factory) { | ||
var AsyncHandlers = { | ||
hasMany: function hasMany(modelRef) { | ||
return serializr.list(serializr.object(modelRef)); | ||
hasMany: function hasMany(modelKlass) { | ||
var defaultSerializer = serializr.list(serializr.object(modelKlass)); | ||
return Object.assign(defaultSerializer, { | ||
model: modelKlass | ||
}); | ||
}, | ||
@@ -128,2 +131,3 @@ belongsTo: function belongsTo(modelKlass, options, propName) { | ||
return { | ||
model: modelKlass, | ||
deserializer: function deserializer(value, cb, context) { | ||
@@ -130,0 +134,0 @@ defaultSerializer.deserializer(value, function (err, model) { |
@@ -118,4 +118,7 @@ import { createModelSchema, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr'; | ||
var AsyncHandlers = { | ||
hasMany: function hasMany(modelRef) { | ||
return list(object(modelRef)); | ||
hasMany: function hasMany(modelKlass) { | ||
var defaultSerializer = list(object(modelKlass)); | ||
return Object.assign(defaultSerializer, { | ||
model: modelKlass | ||
}); | ||
}, | ||
@@ -125,2 +128,3 @@ belongsTo: function belongsTo(modelKlass, options, propName) { | ||
return { | ||
model: modelKlass, | ||
deserializer: function deserializer(value, cb, context) { | ||
@@ -127,0 +131,0 @@ defaultSerializer.deserializer(value, function (err, model) { |
@@ -58,6 +58,13 @@ import { | ||
const AsyncHandlers = { | ||
hasMany: modelRef => list(object(modelRef)), | ||
belongsTo: (modelKlass, options, propName) => { | ||
hasMany(modelKlass) { | ||
const defaultSerializer = list(object(modelKlass)); | ||
return Object.assign(defaultSerializer, { | ||
model: modelKlass, | ||
}); | ||
}, | ||
belongsTo(modelKlass, options, propName) { | ||
const defaultSerializer = object(getDefaultModelSchema(modelKlass)); | ||
return { | ||
model: modelKlass, | ||
deserializer(value, cb, context) { | ||
@@ -64,0 +71,0 @@ defaultSerializer.deserializer(value, (err, model) => { |
{ | ||
"name": "mobx-decorated-models", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Decorators to make using Mobx for model type structures easier", | ||
@@ -5,0 +5,0 @@ "main": "dist/build.full.js", |
@@ -47,2 +47,4 @@ import { Container, Box } from './test-models'; | ||
); | ||
expect(box.metadata.one).toEqual(1); | ||
expect(box.metadata.four.test).toBe(true); | ||
}); | ||
@@ -66,2 +68,3 @@ | ||
box.update({ id: 32, width: 3, depth: 12, height: 4, container }); | ||
expect(box.container).toBeInstanceOf(Container); | ||
expect(box.serialize()).toEqual({ | ||
@@ -68,0 +71,0 @@ container: { |
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
188092
1241