API Reference
@univerjs
@univerjs/core
functions
Onlifecycle

@univerjs/core v0.1.17Docs


Function: OnLifecycle()

function OnLifecycle(lifecycleStage, identifier): (_) => void

Register the decorated class to be automatically instantiated when Univer progresses to the certain lifecycle stage.

Parameters

ParameterTypeDescription
lifecycleStageLifecycleStagesThe lifecycle stage to instantiate this class.
identifierDependencyIdentifier<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

ParameterType
_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)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.