modeled-mobx
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -88,2 +88,4 @@ var mobx = require('mobx'); | ||
function hydrateFromSchema(instance, prop, attrs, schema) { | ||
if (!attrs) return; | ||
if (!schema) { | ||
@@ -135,5 +137,7 @@ instance[prop] = attrs[prop]; | ||
} else { | ||
Object.keys(attrs).forEach(prop => { | ||
hydrateFromSchema(instance, prop, attrs, schema); | ||
}); | ||
const keys = Object.keys(attrs || {}); | ||
for (let i = 0; i < keys.length; i++) { | ||
hydrateFromSchema(instance, keys[i], attrs, schema); | ||
} | ||
} | ||
@@ -140,0 +144,0 @@ |
@@ -88,2 +88,4 @@ import { observable, action, isObservableProp, intercept, isObservableArray, makeObservable } from 'mobx'; | ||
function hydrateFromSchema(instance, prop, attrs, schema) { | ||
if (!attrs) return; | ||
if (!schema) { | ||
@@ -135,5 +137,7 @@ instance[prop] = attrs[prop]; | ||
} else { | ||
Object.keys(attrs).forEach(prop => { | ||
hydrateFromSchema(instance, prop, attrs, schema); | ||
}); | ||
const keys = Object.keys(attrs || {}); | ||
for (let i = 0; i < keys.length; i++) { | ||
hydrateFromSchema(instance, keys[i], attrs, schema); | ||
} | ||
} | ||
@@ -140,0 +144,0 @@ |
@@ -88,2 +88,4 @@ import { observable, action, isObservableProp, intercept, isObservableArray, makeObservable } from 'mobx'; | ||
function hydrateFromSchema(instance, prop, attrs, schema) { | ||
if (!attrs) return; | ||
if (!schema) { | ||
@@ -135,5 +137,7 @@ instance[prop] = attrs[prop]; | ||
} else { | ||
Object.keys(attrs).forEach(prop => { | ||
hydrateFromSchema(instance, prop, attrs, schema); | ||
}); | ||
const keys = Object.keys(attrs || {}); | ||
for (let i = 0; i < keys.length; i++) { | ||
hydrateFromSchema(instance, keys[i], attrs, schema); | ||
} | ||
} | ||
@@ -140,0 +144,0 @@ |
@@ -91,2 +91,4 @@ (function (global, factory) { | ||
function hydrateFromSchema(instance, prop, attrs, schema) { | ||
if (!attrs) return; | ||
if (!schema) { | ||
@@ -138,5 +140,7 @@ instance[prop] = attrs[prop]; | ||
} else { | ||
Object.keys(attrs).forEach(prop => { | ||
hydrateFromSchema(instance, prop, attrs, schema); | ||
}); | ||
const keys = Object.keys(attrs || {}); | ||
for (let i = 0; i < keys.length; i++) { | ||
hydrateFromSchema(instance, keys[i], attrs, schema); | ||
} | ||
} | ||
@@ -143,0 +147,0 @@ |
import { JSON, Model, ModelInstance } from './types'; | ||
export declare const hydrateModel: <T extends Model>(model: T, attrs: any, parent?: any) => InstanceType<T>; | ||
export declare const hydrateInstance: <T extends ModelInstance>(instance: T, attrs: any, parent?: any) => T; | ||
export declare const hydrateModel: <T extends Model>(model: T, attrs?: Object | undefined, parent?: any) => InstanceType<T>; | ||
export declare const hydrateInstance: <T extends ModelInstance>(instance: T, attrs?: Object | undefined, parent?: any) => T; | ||
export declare function serialize<T extends object>(model: T): JSON; |
@@ -11,3 +11,3 @@ import { AnnotationsMap } from 'mobx'; | ||
export interface ModelInstance extends InstanceType<Model> { | ||
hydrate?(attrs: any): void; | ||
hydrate?(attrs?: Object): void; | ||
} | ||
@@ -14,0 +14,0 @@ export interface ModelOption extends Function { |
{ | ||
"name": "modeled-mobx", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"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
108946
992