mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
refactor: rename executeLifeCycleMethod to executeLifeCycleMethod
This commit is contained in:
parent
16c4c96c66
commit
7c2ebf3c02
@ -45,7 +45,7 @@ export default function addonRendererFactory(): IBaseRenderComponent {
|
|||||||
this.__initDataSource(props);
|
this.__initDataSource(props);
|
||||||
this.open = this.open || (() => { });
|
this.open = this.open || (() => { });
|
||||||
this.close = this.close || (() => { });
|
this.close = this.close || (() => { });
|
||||||
this.__excuteLifeCycleMethod('constructor', [...arguments]);
|
this.__executeLifeCycleMethod('constructor', [...arguments]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentWillUnmount() {
|
async componentWillUnmount() {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ import isUseLoop from '../utils/is-use-loop';
|
|||||||
* execute method in schema.lifeCycles with context
|
* execute method in schema.lifeCycles with context
|
||||||
* @PRIVATE
|
* @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) {
|
if (!context || !isSchema(schema) || !method) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -183,32 +183,32 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
__afterInit(_props: IBaseRendererProps) { }
|
__afterInit(_props: IBaseRendererProps) { }
|
||||||
|
|
||||||
static getDerivedStateFromProps(props: IBaseRendererProps, state: any) {
|
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[]) {
|
async getSnapshotBeforeUpdate(...args: any[]) {
|
||||||
this.__excuteLifeCycleMethod('getSnapshotBeforeUpdate', args);
|
this.__executeLifeCycleMethod('getSnapshotBeforeUpdate', args);
|
||||||
this.__debug(`getSnapshotBeforeUpdate - ${this.props?.__schema?.fileName}`);
|
this.__debug(`getSnapshotBeforeUpdate - ${this.props?.__schema?.fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount(...args: any[]) {
|
async componentDidMount(...args: any[]) {
|
||||||
this.reloadDataSource();
|
this.reloadDataSource();
|
||||||
this.__excuteLifeCycleMethod('componentDidMount', args);
|
this.__executeLifeCycleMethod('componentDidMount', args);
|
||||||
this.__debug(`componentDidMount - ${this.props?.__schema?.fileName}`);
|
this.__debug(`componentDidMount - ${this.props?.__schema?.fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidUpdate(...args: any[]) {
|
async componentDidUpdate(...args: any[]) {
|
||||||
this.__excuteLifeCycleMethod('componentDidUpdate', args);
|
this.__executeLifeCycleMethod('componentDidUpdate', args);
|
||||||
this.__debug(`componentDidUpdate - ${this.props.__schema.fileName}`);
|
this.__debug(`componentDidUpdate - ${this.props.__schema.fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentWillUnmount(...args: any[]) {
|
async componentWillUnmount(...args: any[]) {
|
||||||
this.__excuteLifeCycleMethod('componentWillUnmount', args);
|
this.__executeLifeCycleMethod('componentWillUnmount', args);
|
||||||
this.__debug(`componentWillUnmount - ${this.props?.__schema?.fileName}`);
|
this.__debug(`componentWillUnmount - ${this.props?.__schema?.fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidCatch(...args: any[]) {
|
async componentDidCatch(...args: any[]) {
|
||||||
this.__excuteLifeCycleMethod('componentDidCatch', args);
|
this.__executeLifeCycleMethod('componentDidCatch', args);
|
||||||
console.warn(args);
|
console.warn(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
* execute method in schema.lifeCycles
|
* execute method in schema.lifeCycles
|
||||||
* @PRIVATE
|
* @PRIVATE
|
||||||
*/
|
*/
|
||||||
__excuteLifeCycleMethod = (method: string, args?: any) => {
|
__executeLifeCycleMethod = (method: string, args?: any) => {
|
||||||
excuteLifeCycleMethod(this, this.props.__schema, method, args, this.props.thisRequiredInJSE);
|
executeLifeCycleMethod(this, this.props.__schema, method, args, this.props.thisRequiredInJSE);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -406,7 +406,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
|
|
||||||
__render = () => {
|
__render = () => {
|
||||||
const schema = this.props.__schema;
|
const schema = this.props.__schema;
|
||||||
this.__excuteLifeCycleMethod('render');
|
this.__executeLifeCycleMethod('render');
|
||||||
this.__writeCss(this.props);
|
this.__writeCss(this.props);
|
||||||
|
|
||||||
const { engine } = this.context;
|
const { engine } = this.context;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export default function blockRendererFactory(): IBaseRenderComponent {
|
|||||||
const schema = props.__schema || {};
|
const schema = props.__schema || {};
|
||||||
this.state = this.__parseData(schema.state || {});
|
this.state = this.__parseData(schema.state || {});
|
||||||
this.__initDataSource(props);
|
this.__initDataSource(props);
|
||||||
this.__excuteLifeCycleMethod('constructor', [...arguments]);
|
this.__executeLifeCycleMethod('constructor', [...arguments]);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export default function componentRendererFactory(): IBaseRenderComponent {
|
|||||||
const schema = props.__schema || {};
|
const schema = props.__schema || {};
|
||||||
this.state = this.__parseData(schema.state || {});
|
this.state = this.__parseData(schema.state || {});
|
||||||
this.__initDataSource(props);
|
this.__initDataSource(props);
|
||||||
this.__excuteLifeCycleMethod('constructor', arguments as any);
|
this.__executeLifeCycleMethod('constructor', arguments as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export default function pageRendererFactory(): IBaseRenderComponent {
|
|||||||
const schema = props.__schema || {};
|
const schema = props.__schema || {};
|
||||||
this.state = this.__parseData(schema.state || {});
|
this.state = this.__parseData(schema.state || {});
|
||||||
this.__initDataSource(props);
|
this.__initDataSource(props);
|
||||||
this.__excuteLifeCycleMethod('constructor', [props, ...rest]);
|
this.__executeLifeCycleMethod('constructor', [props, ...rest]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
|
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
|
||||||
@ -44,7 +44,6 @@ export default function pageRendererFactory(): IBaseRenderComponent {
|
|||||||
});
|
});
|
||||||
this.__render();
|
this.__render();
|
||||||
|
|
||||||
|
|
||||||
const { Page } = __components;
|
const { Page } = __components;
|
||||||
if (Page) {
|
if (Page) {
|
||||||
return this.__renderComp(Page, { pageContext: this });
|
return this.__renderComp(Page, { pageContext: this });
|
||||||
|
|||||||
@ -281,7 +281,7 @@ export type IBaseRendererInstance = IGeneralComponent<
|
|||||||
__beforeInit(props: IBaseRendererProps): void;
|
__beforeInit(props: IBaseRendererProps): void;
|
||||||
__init(props: IBaseRendererProps): void;
|
__init(props: IBaseRendererProps): void;
|
||||||
__afterInit(props: IBaseRendererProps): void;
|
__afterInit(props: IBaseRendererProps): void;
|
||||||
__excuteLifeCycleMethod(method: string, args?: any[]): void;
|
__executeLifeCycleMethod(method: string, args?: any[]): void;
|
||||||
__bindCustomMethods(props: IBaseRendererProps): void;
|
__bindCustomMethods(props: IBaseRendererProps): void;
|
||||||
__generateCtx(ctx: Record<string, any>): void;
|
__generateCtx(ctx: Record<string, any>): void;
|
||||||
__parseData(data: any, ctx?: any): any;
|
__parseData(data: any, ctx?: any): any;
|
||||||
|
|||||||
@ -121,7 +121,7 @@ describe('Base Render methods', () => {
|
|||||||
// it('should excute lifecycle.componentDidCatch when defined', () => {
|
// it('should excute lifecycle.componentDidCatch when defined', () => {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('__excuteLifeCycleMethod should work', () => {
|
// it('__executeLifeCycleMethod should work', () => {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('reloadDataSource should work', () => {
|
// it('reloadDataSource should work', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user