refactor: change __setLifeCycleMethods to its actual meaning __excuteLifeCycleMethod

This commit is contained in:
JackLian 2022-07-05 15:38:28 +08:00 committed by 刘菊萍(絮黎)
parent 951d1cb103
commit 12f67dcdeb
6 changed files with 13 additions and 13 deletions

View File

@ -45,7 +45,7 @@ export default function addonRendererFactory(): IBaseRenderComponent {
this.__initDataSource(props);
this.open = this.open || (() => { });
this.close = this.close || (() => { });
this.__setLifeCycleMethods('constructor', [...arguments]);
this.__excuteLifeCycleMethod('constructor', [...arguments]);
}
async componentWillUnmount() {

View File

@ -131,28 +131,28 @@ export default function baseRendererFactory(): IBaseRenderComponent {
}
async getSnapshotBeforeUpdate(...args: any[]) {
this.__setLifeCycleMethods('getSnapshotBeforeUpdate', args);
this.__excuteLifeCycleMethod('getSnapshotBeforeUpdate', args);
this.__debug(`getSnapshotBeforeUpdate - ${this.props?.__schema?.fileName}`);
}
async componentDidMount(...args: any[]) {
this.reloadDataSource();
this.__setLifeCycleMethods('componentDidMount', args);
this.__excuteLifeCycleMethod('componentDidMount', args);
this.__debug(`componentDidMount - ${this.props?.__schema?.fileName}`);
}
async componentDidUpdate(...args: any[]) {
this.__setLifeCycleMethods('componentDidUpdate', args);
this.__excuteLifeCycleMethod('componentDidUpdate', args);
this.__debug(`componentDidUpdate - ${this.props.__schema.fileName}`);
}
async componentWillUnmount(...args: any[]) {
this.__setLifeCycleMethods('componentWillUnmount', args);
this.__excuteLifeCycleMethod('componentWillUnmount', args);
this.__debug(`componentWillUnmount - ${this.props?.__schema?.fileName}`);
}
async componentDidCatch(...args: any[]) {
this.__setLifeCycleMethods('componentDidCatch', args);
this.__excuteLifeCycleMethod('componentDidCatch', args);
console.warn(args);
}
@ -194,7 +194,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
}
}
__setLifeCycleMethods = (method: string, args?: any) => {
__excuteLifeCycleMethod = (method: string, args?: any) => {
const lifeCycleMethods = getValue(this.props.__schema, 'lifeCycles', {});
let fn = lifeCycleMethods[method];
if (fn) {
@ -360,7 +360,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
__render = () => {
const schema = this.props.__schema;
this.__setLifeCycleMethods('render');
this.__excuteLifeCycleMethod('render');
this.__writeCss();
const { engine } = this.context;

View File

@ -13,7 +13,7 @@ export default function blockRendererFactory(): IBaseRenderComponent {
const schema = props.__schema || {};
this.state = this.__parseData(schema.state || {});
this.__initDataSource(props);
this.__setLifeCycleMethods('constructor', [...arguments]);
this.__excuteLifeCycleMethod('constructor', [...arguments]);
}
render() {

View File

@ -15,7 +15,7 @@ export default function componentRendererFactory(): IBaseRenderComponent {
const schema = props.__schema || {};
this.state = this.__parseData(schema.state || {});
this.__initDataSource(props);
this.__setLifeCycleMethods('constructor', arguments as any);
this.__excuteLifeCycleMethod('constructor', arguments as any);
}
render() {

View File

@ -15,7 +15,7 @@ export default function pageRendererFactory(): IBaseRenderComponent {
const schema = props.__schema || {};
this.state = this.__parseData(schema.state || {});
this.__initDataSource(props);
this.__setLifeCycleMethods('constructor', [props, ...rest]);
this.__excuteLifeCycleMethod('constructor', [props, ...rest]);
}
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
@ -40,7 +40,7 @@ export default function pageRendererFactory(): IBaseRenderComponent {
this.__bindCustomMethods(this.props);
this.__initDataSource(this.props);
// this.__setLifeCycleMethods('constructor', arguments);
// this.__excuteLifeCycleMethod('constructor', arguments);
this.__generateCtx({
page: this,

View File

@ -240,7 +240,7 @@ export type IBaseRendererInstance = IGeneralComponent<
__beforeInit(props: IBaseRendererProps): void;
__init(props: IBaseRendererProps): void;
__afterInit(props: IBaseRendererProps): void;
__setLifeCycleMethods(method: string, args?: any[]): void;
__excuteLifeCycleMethod(method: string, args?: any[]): void;
__bindCustomMethods(props: IBaseRendererProps): void;
__generateCtx(ctx: Record<string, any>): void;
__parseData(data: any, ctx?: any): any;