BlockSuite API Documentation / @blocksuite/block-std / UIEventDispatcher
Class: UIEventDispatcher 
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
 static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends 
Constructors 
new UIEventDispatcher() 
new UIEventDispatcher(
std):UIEventDispatcher
Parameters 
• std: BlockStdScope
Returns 
Overrides 
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:109
Properties 
disposables 
disposables:
DisposableGroup
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:95
std 
readonlystd:BlockStdScope
Inherited from 
Defined in 
packages/framework/block-std/src/extension/lifecycle-watcher.ts:30
key 
readonlystatickey:"UIEventDispatcher"='UIEventDispatcher'
Overrides 
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:76
Accessors 
active 
getactive():boolean
Returns 
boolean
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:101
host 
gethost():EditorHost
Returns 
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:105
Methods 
add() 
add(
name,handler,options?): () =>void
Parameters 
• name: "blur" | "click" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "cut" | "copy" | "paste" | "beforeInput" | "focus" | "drop" | "contextMenu" | "wheel"
• handler: UIEventHandler
• options?: EventOptions
Returns 
Function
Returns 
void
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:291
bindHotkey() 
bindHotkey(...
args): () =>void
Parameters 
• ...args: [Record<string, UIEventHandler>, EventOptions]
Returns 
Function
Returns 
void
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:92
buildEventScope() 
buildEventScope(
name,blocks):undefined|EventHandlerRunner[]
Parameters 
• name: "blur" | "click" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "cut" | "copy" | "paste" | "beforeInput" | "focus" | "drop" | "contextMenu" | "wheel"
• blocks: string[]
Returns 
undefined | EventHandlerRunner[]
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:307
created() 
created():
void
Called when std is created.
Returns 
void
Inherited from 
Defined in 
packages/framework/block-std/src/extension/lifecycle-watcher.ts:54
mounted() 
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.
Returns 
void
Overrides 
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:350
rendered() 
rendered():
void
Called when std.render is called.
Returns 
void
Inherited from 
Defined in 
packages/framework/block-std/src/extension/lifecycle-watcher.ts:65
run() 
run(
name,context,runners?):void
Parameters 
• name: "blur" | "click" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "cut" | "copy" | "paste" | "beforeInput" | "focus" | "drop" | "contextMenu" | "wheel"
• context: UIEventStateContext
• runners?: EventHandlerRunner[]
Returns 
void
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:364
unmounted() 
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns 
void
Overrides 
Defined in 
packages/framework/block-std/src/event/dispatcher.ts:388
setup() 
staticsetup(di):void
Parameters 
• di: Container
Returns 
void
Inherited from 
Defined in 
packages/framework/block-std/src/extension/lifecycle-watcher.ts:34