Skip to content

BlockSuite API Documentation / @blocksuite/block-std / ServiceManager

Class: ServiceManager

Defined in: packages/framework/block-std/src/service/index.ts:4

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.

ts
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:

  1. created: Called when the std is created.
  2. rendered: Called when std.render is called.
  3. mounted: Called when the editor host is mounted.
  4. unmounted: Called when the editor host is unmounted.

Extends

Constructors

new ServiceManager()

new ServiceManager(std): ServiceManager

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:28

Parameters

std

BlockStdScope

Returns

ServiceManager

Inherited from

LifeCycleWatcher.constructor

Properties

std

readonly std: BlockStdScope

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:28

Inherited from

LifeCycleWatcher.std


key

readonly static key: "serviceManager" = 'serviceManager'

Defined in: packages/framework/block-std/src/service/index.ts:5

Overrides

LifeCycleWatcher.key

Methods

created()

created(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:52

Called when std is created.

Returns

void

Inherited from

LifeCycleWatcher.created


mounted()

mounted(): void

Defined in: packages/framework/block-std/src/service/index.ts:7

Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.

Returns

void

Overrides

LifeCycleWatcher.mounted


rendered()

rendered(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:63

Called when std.render is called.

Returns

void

Inherited from

LifeCycleWatcher.rendered


unmounted()

unmounted(): void

Defined in: packages/framework/block-std/src/service/index.ts:15

Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.

Returns

void

Overrides

LifeCycleWatcher.unmounted


setup()

static setup(di): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:32

Parameters

di

Container

Returns

void

Inherited from

LifeCycleWatcher.setup