跳至主要內容

Class: life_cycle

muzzik大约 3 分钟

index / life_cycle

Class: life_cycle

生命周期

Remarks

用于模块生命周期控制,注意所有生命周期函数 onLoad、open ... 等都会自动执行父类函数再执行子类函数,不必手动 super.xxxopen in new window 调用

  • open 顺序: 子 -> 父

  • close 顺序: 父 -> 子

Hierarchy

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new life_cycle(...args)

Parameters

NameType
...argsany[]

Overrides

mk_layer.constructor

Defined in

assets/@framework/module/mk_life_cycle.ts:84open in new window

Properties

init_data

Optional init_data: any

初始化数据

Defined in

assets/@framework/module/mk_life_cycle.ts:120open in new window


event_target_as

Readonly event_target_as: { targetOff: (target: any) => any }[] | { target_off: (target: any) => any }[] = []

事件对象列表

Remarks

模块关闭后自动清理事件

Defined in

assets/@framework/module/mk_life_cycle.ts:127open in new window


_static_b

Protected _static_b: boolean = true

静态模块

Defined in

assets/@framework/module/mk_life_cycle.ts:158open in new window


_load_task

Protected _load_task: status<void>

load任务

Defined in

assets/@framework/module/mk_life_cycle.ts:160open in new window


_open_task

Protected _open_task: status<void>

open任务

Defined in

assets/@framework/module/mk_life_cycle.ts:162open in new window


_state

Protected _state: run_state = _mk_life_cycle.run_state.close

运行状态

Defined in

assets/@framework/module/mk_life_cycle.ts:164open in new window

Accessors

valid_b

get valid_b(): boolean

有效状态

Returns

boolean

Remarks

表示模块未在(关闭/关闭中)状态

Defined in

assets/@framework/module/mk_life_cycle.ts:134open in new window


static_b

get static_b(): boolean

静态模块

Returns

boolean

Defined in

assets/@framework/module/mk_life_cycle.ts:145open in new window


config

set config(config_): void

设置模块配置

Parameters

NameType
config_create_config

Returns

void

Defined in

assets/@framework/module/mk_life_cycle.ts:150open in new window


_log

Protected get _log(): logger

日志

Returns

logger

Defined in

assets/@framework/module/mk_life_cycle.ts:172open in new window

Methods

onLoad

Protected onLoad(): void

Returns

void

Overrides

layer.onLoad

Defined in

assets/@framework/module/mk_life_cycle.ts:180open in new window


create

Protected Optional create(): void | Promise<void>

创建

Returns

void | Promise<void>

Remarks

可在此处初始化视图状态

  • 静态模块:onLoad 时调用

  • 动态模块:addChild 后调用

Defined in

assets/@framework/module/mk_life_cycle.ts:204open in new window


init

init(data_?): void | Promise<void>

初始化

Parameters

NameTypeDescription
data_?any初始化数据

Returns

void | Promise<void>

Remarks

所有依赖 init_data 初始化的逻辑都应在此进行

  • 静态模块:外部自行调用,常用于更新 item 或者静态模块

  • 动态模块:onLoad 后,open 前调用

Defined in

assets/@framework/module/mk_life_cycle.ts:217open in new window


open

Protected Optional open(): void | Promise<void>

打开

Returns

void | Promise<void>

Remarks

init 后执行,在此处执行无需 init_data 支持的模块初始化操作

Defined in

assets/@framework/module/mk_life_cycle.ts:230open in new window


close

Optional close(): void | Promise<void>

关闭

Returns

void | Promise<void>

Remarks

内部调用:生命周期
外部调用:自动回收模块

Defined in

assets/@framework/module/mk_life_cycle.ts:238open in new window


late_close

Protected Optional late_close(): void | Promise<void>

关闭后

Returns

void | Promise<void>

Remarks

在子模块 close 和 late_close 后执行

Defined in

assets/@framework/module/mk_life_cycle.ts:247open in new window


follow_release

follow_release<T>(object_): T

Type parameters

NameType
TObject

Parameters

NameType
object_T

Returns

T

Implementation of

mk_asset_.follow_release_object.follow_release

Defined in

assets/@framework/module/mk_life_cycle.ts:267open in new window


cancel_release

cancel_release<T>(object_): T

Type parameters

NameType
TObject

Parameters

NameType
object_T

Returns

T

Implementation of

mk_asset_.follow_release_object.cancel_release

Defined in

assets/@framework/module/mk_life_cycle.ts:290open in new window

📣 觉得很赞?分享给你的朋友吧!