refactor: rename executeLifeCycleMethod to executeLifeCycleMethod

This commit is contained in:
liujuping 2023-02-21 11:46:22 +08:00 committed by 林熠
parent 16c4c96c66
commit 7c2ebf3c02
7 changed files with 16 additions and 17 deletions

View File

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

View File

@ -40,7 +40,7 @@ import isUseLoop from '../utils/is-use-loop';
* execute method in schema.lifeCycles with context
* @PRIVATE
*/
export function excuteLifeCycleMethod(context: any, schema: IPublicTypeNodeSchema, method: string, args: any, thisRequiredInJSE: boolean | undefined): any {
export function executeLifeCycleMethod(context: any, schema: IPublicTypeNodeSchema, method: string, args: any, thisRequiredInJSE: boolean | undefined): any {
if (!context || !isSchema(schema) || !method) {
return;
}
@ -183,32 +183,32 @@ export default function baseRendererFactory(): IBaseRenderComponent {
__afterInit(_props: IBaseRendererProps) { }
static getDerivedStateFromProps(props: IBaseRendererProps, state: any) {
return excuteLifeCycleMethod(this, props?.__schema, 'getDerivedStateFromProps', [props, state], props.thisRequiredInJSE);
return executeLifeCycleMethod(this, props?.__schema, 'getDerivedStateFromProps', [props, state], props.thisRequiredInJSE);
}
async getSnapshotBeforeUpdate(...args: any[]) {
this.__excuteLifeCycleMethod('getSnapshotBeforeUpdate', args);
this.__executeLifeCycleMethod('getSnapshotBeforeUpdate', args);
this.__debug(`getSnapshotBeforeUpdate - ${this.props?.__schema?.fileName}`);
}
async componentDidMount(...args: any[]) {
this.reloadDataSource();
this.__excuteLifeCycleMethod('componentDidMount', args);
this.__executeLifeCycleMethod('componentDidMount', args);
this.__debug(`componentDidMount - ${this.props?.__schema?.fileName}`);
}
async componentDidUpdate(...args: any[]) {
this.__excuteLifeCycleMethod('componentDidUpdate', args);
this.__executeLifeCycleMethod('componentDidUpdate', args);
this.__debug(`componentDidUpdate - ${this.props.__schema.fileName}`);
}
async componentWillUnmount(...args: any[]) {
this.__excuteLifeCycleMethod('componentWillUnmount', args);
this.__executeLifeCycleMethod('componentWillUnmount', args);
this.__debug(`componentWillUnmount - ${this.props?.__schema?.fileName}`);
}
async componentDidCatch(...args: any[]) {
this.__excuteLifeCycleMethod('componentDidCatch', args);
this.__executeLifeCycleMethod('componentDidCatch', args);
console.warn(args);
}
@ -248,8 +248,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
* execute method in schema.lifeCycles
* @PRIVATE
*/
__excuteLifeCycleMethod = (method: string, args?: any) => {
excuteLifeCycleMethod(this, this.props.__schema, method, args, this.props.thisRequiredInJSE);
__executeLifeCycleMethod = (method: string, args?: any) => {
executeLifeCycleMethod(this, this.props.__schema, method, args, this.props.thisRequiredInJSE);
};
/**
@ -406,7 +406,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
__render = () => {
const schema = this.props.__schema;
this.__excuteLifeCycleMethod('render');
this.__executeLifeCycleMethod('render');
this.__writeCss(this.props);
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.__excuteLifeCycleMethod('constructor', [...arguments]);
this.__executeLifeCycleMethod('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.__excuteLifeCycleMethod('constructor', arguments as any);
this.__executeLifeCycleMethod('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.__excuteLifeCycleMethod('constructor', [props, ...rest]);
this.__executeLifeCycleMethod('constructor', [props, ...rest]);
}
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
@ -44,7 +44,6 @@ export default function pageRendererFactory(): IBaseRenderComponent {
});
this.__render();
const { Page } = __components;
if (Page) {
return this.__renderComp(Page, { pageContext: this });

View File

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

View File

@ -121,7 +121,7 @@ describe('Base Render methods', () => {
// it('should excute lifecycle.componentDidCatch when defined', () => {
// });
// it('__excuteLifeCycleMethod should work', () => {
// it('__executeLifeCycleMethod should work', () => {
// });
// it('reloadDataSource should work', () => {