Lifecycle
Global lifecycle
- Starting: Initialization, before any business unit exists.
- Ready: The first business unit has been created; later units do not retrigger it.
- Rendered: The standard UI has performed its first render switch, not necessarily finished all asynchronous content.
- Steady: The standard UI enters this stage after a delay following Rendered, without waiting for all asynchronous tasks.
Facade API
const currentStage = univerAPI.getCurrentLifecycleStage()const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => { console.log(stage)})What the event reports
LifeCycleChanged reports Univer’s global stage. For example, loading plugin B after global Ready calls B’s onReady(), but does not emit another global Ready event.
When you add a listener, its callback may immediately receive the current stage, including Starting. To simply check the current stage, call univerAPI.getCurrentLifecycleStage() directly.
To remove a listener, you can use the returned disposable object:
disposable.dispose()Plugin lifecycle hooks
A plugin runs onStarting() when it loads, then catches up to the current global stage. Choose when B loads to compare its hook calls with A’s.
Slowed down to show synchronous hook calls.
General plugins load on registration; business-type plugins usually load before the first unit of that type is constructed. New plugins for an already started type load in a deferred batch. Explicit dependencies can trigger earlier loading.
Each batch invokes hooks synchronously, stage by stage and in dependency order, without awaiting asynchronous work. Check the specific unit, DOM element, or resource before accessing it.
How is this guide?