Comparing version 1.1.1 to 1.1.2
import * as React from 'react'; | ||
import { IViewProps, IViewModel, IComponentDefinition } from './interfaces/index'; | ||
export declare function createComponent<TComponentProps>(definition: IComponentDefinition): (ViewModel: any) => React.ComponentClass<TComponentProps & IViewProps<IViewModel>>; | ||
import { IComponentProps, IViewModel, IComponentDefinition } from './interfaces/index'; | ||
export declare function createComponent<TComponentProps>(definition: IComponentDefinition): (ViewModel: any) => React.ComponentClass<TComponentProps & IComponentProps<IViewModel>>; |
@@ -1,2 +0,2 @@ | ||
import { IComponentState, IViewProps, IViewModel } from './interfaces/index'; | ||
export declare function createModel(state: IComponentState, props: IViewProps<IViewModel>, ctx: any, ViewModel: any): IComponentState; | ||
import { IComponentState, IComponentProps, IViewModel } from './interfaces/index'; | ||
export declare function createModel(state: IComponentState, props: IComponentProps<IViewModel>, ctx: any, ViewModel: any): IComponentState; |
@@ -10,1 +10,2 @@ export * from './IComponentContext'; | ||
export * from './ILinkDisposer'; | ||
export * from './IComponentProps'; |
@@ -57,2 +57,6 @@ "use strict"; | ||
if (this.linkDisposer) this.linkDisposer(); | ||
// dispose the model ref, if any | ||
if (this.props.modelRef) { | ||
this.props.modelRef(null); | ||
} | ||
// ...then dispose the model | ||
@@ -59,0 +63,0 @@ disposeModel_1.disposeModel(this.state); |
@@ -10,5 +10,10 @@ "use strict"; | ||
} : _ctx$resolver; | ||
var _props$modelRef = props.modelRef; | ||
var modelRef = _props$modelRef === undefined ? function () { | ||
return true; | ||
} : _props$modelRef; | ||
// if model is passed from props and is new, set it | ||
if (props.model && state.model !== props.model) { | ||
modelRef(props.model); | ||
disposeModel_1.disposeModel(state); | ||
@@ -19,3 +24,5 @@ return { model: props.model, shouldDispose: false }; | ||
if (!state.model) { | ||
return { model: resolver(ViewModel), shouldDispose: true }; | ||
var model = resolver(ViewModel); | ||
modelRef(model); | ||
return { model: model, shouldDispose: true }; | ||
} | ||
@@ -22,0 +29,0 @@ // nothing done, untouched! |
{ | ||
"name": "mobx-mvvm", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "MVVM solution based on React and MobX", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
19905
38
393