@univerjs/core v0.1.17 • Docs
Function: OnLifecycle()
function OnLifecycle(lifecycleStage, identifier): (_) => void
Register the decorated class to be automatically instantiated when Univer progresses to the certain lifecycle stage.
Parameters
Parameter | Type | Description |
---|---|---|
lifecycleStage | LifecycleStages | The lifecycle stage to instantiate this class. |
identifier | DependencyIdentifier <unknown > | The dependency identifier of the class. Usually, it is the class itself unless you bind this class with another injection identifier. |
Returns
Function
Parameters
Parameter | Type |
---|---|
_ | Ctor <unknown > |
Returns
void
Example
// Ignore the `\` below. This is JSDoc's bug.
\@OnLifecycle(LifecycleStages.Ready, MyService)
class MyService {
}
@example
// Ignore the `` below. This is JSDoc's bug.
@OnLifecycle(LifecycleStages.Rendered, IMyService)
class MyService implements IMyService {
}
Defined in
submodules/univer/packages/core/src/services/lifecycle/lifecycle.ts:74 (opens in a new tab)