mobx-view-model
Version:
MobX ViewModel power for ReactJS
68 lines • 2.62 kB
TypeScript
import { ViewModelsConfig } from '../config/index.js';
import { AnyObject, EmptyObject, Maybe } from '../utils/types.js';
import { ViewModel } from './view-model.js';
import { ViewModelStore } from './view-model.store.js';
import { AnyViewModel, PayloadCompareFn, ViewModelParams } from './view-model.types.js';
export declare class ViewModelBase<Payload extends AnyObject = EmptyObject, ParentViewModel extends AnyViewModel | null = null, ComponentProps extends AnyObject = AnyObject> implements ViewModel<Payload, ParentViewModel> {
protected vmParams: ViewModelParams<Payload, ParentViewModel, ComponentProps>;
private abortController;
unmountSignal: AbortSignal;
id: string;
private _isMounted;
private _isUnmounting;
private _payload;
vmConfig: ViewModelsConfig;
protected isPayloadEqual?: PayloadCompareFn<Payload>;
/**
* @deprecated use `vmParams`. This property will be removed in next major release
* Reason: this word is very useful for users, so `vmParams` is more library-targered naming
*/
protected params: ViewModelParams<Payload, ParentViewModel, ComponentProps>;
protected props: ComponentProps;
constructor(vmParams: ViewModelParams<Payload, ParentViewModel, ComponentProps>);
get payload(): Payload;
protected get viewModels(): ViewModelStore;
get isMounted(): boolean;
get isUnmounting(): boolean;
willUnmount(): void;
/**
* Empty method to be overridden
*/
willMount(): void;
/**
* The method is called when the view starts mounting
*/
mount(): void;
/**
* The method is called when the view was mounted
*/
didMount(): void;
/**
* The method is called when the view starts unmounting
*/
unmount(): void;
/**
* The method is called when the view was unmounted
*/
didUnmount(): void;
/**
* The method is called when the payload of the view model was changed
*
* The state - "was changed" is determined inside the setPayload method
*/
payloadChanged(payload: Payload, prevPayload: Payload): void;
/**
* Returns the parent view model
* For this property to work, the getParentViewModel method is required
*/
get parentViewModel(): ParentViewModel;
/**
* The method is called when the payload changes in the react component
*/
setPayload(payload: Payload): void;
/**
* The method of getting the parent view model
*/
protected getParentViewModel(parentViewModelId: Maybe<string>): ParentViewModel;
}
//# sourceMappingURL=view-model.base.d.ts.map