modeled-mobx
Advanced tools
Comparing version 0.0.2-0 to 0.0.3-0
@@ -32,8 +32,18 @@ var mobx = require('mobx'); | ||
const m = new model(); | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
if (typeof m.hydrate == 'function') { | ||
m.hydrate(attrs); | ||
} else { | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
} | ||
return m; | ||
} | ||
function serialize(model) { | ||
if (typeof model['serialize'] == 'function') { | ||
return model['serialize'](); | ||
} | ||
const schema = getSchema(model.constructor); | ||
@@ -40,0 +50,0 @@ |
@@ -32,8 +32,18 @@ import { observable, intercept, makeObservable } from 'mobx'; | ||
const m = new model(); | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
if (typeof m.hydrate == 'function') { | ||
m.hydrate(attrs); | ||
} else { | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
} | ||
return m; | ||
} | ||
function serialize(model) { | ||
if (typeof model['serialize'] == 'function') { | ||
return model['serialize'](); | ||
} | ||
const schema = getSchema(model.constructor); | ||
@@ -40,0 +50,0 @@ |
@@ -32,8 +32,18 @@ import { observable, intercept, makeObservable } from 'mobx'; | ||
const m = new model(); | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
if (typeof m.hydrate == 'function') { | ||
m.hydrate(attrs); | ||
} else { | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
} | ||
return m; | ||
} | ||
function serialize(model) { | ||
if (typeof model['serialize'] == 'function') { | ||
return model['serialize'](); | ||
} | ||
const schema = getSchema(model.constructor); | ||
@@ -40,0 +50,0 @@ |
@@ -35,8 +35,18 @@ (function (global, factory) { | ||
const m = new model(); | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
if (typeof m.hydrate == 'function') { | ||
m.hydrate(attrs); | ||
} else { | ||
Object.keys(attrs).forEach(a => { | ||
m[a] = attrs[a]; | ||
}); | ||
} | ||
return m; | ||
} | ||
function serialize(model) { | ||
if (typeof model['serialize'] == 'function') { | ||
return model['serialize'](); | ||
} | ||
const schema = getSchema(model.constructor); | ||
@@ -43,0 +53,0 @@ |
{ | ||
"name": "modeled-mobx", | ||
"version": "0.0.2-0", | ||
"version": "0.0.3-0", | ||
"description": "MobX powered classes with type-coercion and serialization/hydration", | ||
@@ -5,0 +5,0 @@ "author": "nathanstitt", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
72922
712