import{_ as a,c as r,az as t,o as i}from"./chunks/framework.BlkfTNxp.js";const f=JSON.parse('{"title":"Class: ServiceManager","description":"","frontmatter":{},"headers":[],"relativePath":"api/@blocksuite/block-std/classes/ServiceManager.md","filePath":"api/@blocksuite/block-std/classes/ServiceManager.md"}'),o={name:"api/@blocksuite/block-std/classes/ServiceManager.md"};function d(n,e,c,h,s,l){return i(),r("div",null,e[0]||(e[0]=[t(`<p><a href="./../../../">BlockSuite API Documentation</a> / <a href="./../">@blocksuite/block-std</a> / ServiceManager</p><h1 id="class-servicemanager" tabindex="-1">Class: ServiceManager <a class="header-anchor" href="#class-servicemanager" aria-label="Permalink to &quot;Class: ServiceManager&quot;">​</a></h1><p>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.</p><p>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.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">class</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> MyLifeCycleWatcher</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> extends</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LifeCycleWatcher</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> static</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> override</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> readonly</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;my-life-cycle-watcher&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span></code></pre></div><p>In the life cycle watcher, the methods will be called in the following order:</p><ol><li><code>created</code>: Called when the std is created.</li><li><code>rendered</code>: Called when <code>std.render</code> is called.</li><li><code>mounted</code>: Called when the editor host is mounted.</li><li><code>unmounted</code>: Called when the editor host is unmounted.</li></ol><h2 id="extends" tabindex="-1">Extends <a class="header-anchor" href="#extends" aria-label="Permalink to &quot;Extends&quot;">​</a></h2><ul><li><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a></li></ul><h2 id="constructors" tabindex="-1">Constructors <a class="header-anchor" href="#constructors" aria-label="Permalink to &quot;Constructors&quot;">​</a></h2><h3 id="new-servicemanager" tabindex="-1">new ServiceManager() <a class="header-anchor" href="#new-servicemanager" aria-label="Permalink to &quot;new ServiceManager()&quot;">​</a></h3><blockquote><p><strong>new ServiceManager</strong>(<code>std</code>): <a href="./ServiceManager.html"><code>ServiceManager</code></a></p></blockquote><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to &quot;Parameters&quot;">​</a></h4><h5 id="std" tabindex="-1">std <a class="header-anchor" href="#std" aria-label="Permalink to &quot;std&quot;">​</a></h5><p><a href="./BlockStdScope.html"><code>BlockStdScope</code></a></p><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><a href="./ServiceManager.html"><code>ServiceManager</code></a></p><h4 id="inherited-from" tabindex="-1">Inherited from <a class="header-anchor" href="#inherited-from" aria-label="Permalink to &quot;Inherited from&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#constructors"><code>constructor</code></a></p><h4 id="defined-in" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/extension/lifecycle-watcher.ts:30</p><h2 id="properties" tabindex="-1">Properties <a class="header-anchor" href="#properties" aria-label="Permalink to &quot;Properties&quot;">​</a></h2><h3 id="std-1" tabindex="-1">std <a class="header-anchor" href="#std-1" aria-label="Permalink to &quot;std&quot;">​</a></h3><blockquote><p><code>readonly</code> <strong>std</strong>: <a href="./BlockStdScope.html"><code>BlockStdScope</code></a></p></blockquote><h4 id="inherited-from-1" tabindex="-1">Inherited from <a class="header-anchor" href="#inherited-from-1" aria-label="Permalink to &quot;Inherited from&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#std-1"><code>std</code></a></p><h4 id="defined-in-1" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-1" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/extension/lifecycle-watcher.ts:30</p><hr><h3 id="key" tabindex="-1">key <a class="header-anchor" href="#key" aria-label="Permalink to &quot;key&quot;">​</a></h3><blockquote><p><code>readonly</code> <code>static</code> <strong>key</strong>: <code>&quot;serviceManager&quot;</code> = <code>&#39;serviceManager&#39;</code></p></blockquote><h4 id="overrides" tabindex="-1">Overrides <a class="header-anchor" href="#overrides" aria-label="Permalink to &quot;Overrides&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#key"><code>key</code></a></p><h4 id="defined-in-2" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-2" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/service/index.ts:5</p><h2 id="methods" tabindex="-1">Methods <a class="header-anchor" href="#methods" aria-label="Permalink to &quot;Methods&quot;">​</a></h2><h3 id="created" tabindex="-1">created() <a class="header-anchor" href="#created" aria-label="Permalink to &quot;created()&quot;">​</a></h3><blockquote><p><strong>created</strong>(): <code>void</code></p></blockquote><p>Called when std is created.</p><h4 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><code>void</code></p><h4 id="inherited-from-2" tabindex="-1">Inherited from <a class="header-anchor" href="#inherited-from-2" aria-label="Permalink to &quot;Inherited from&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#created"><code>created</code></a></p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/extension/lifecycle-watcher.ts:54</p><hr><h3 id="mounted" tabindex="-1">mounted() <a class="header-anchor" href="#mounted" aria-label="Permalink to &quot;mounted()&quot;">​</a></h3><blockquote><p><strong>mounted</strong>(): <code>void</code></p></blockquote><p>Called when editor host is mounted. Which means the editor host emit the <code>connectedCallback</code> lifecycle event.</p><h4 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><code>void</code></p><h4 id="overrides-1" tabindex="-1">Overrides <a class="header-anchor" href="#overrides-1" aria-label="Permalink to &quot;Overrides&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#mounted"><code>mounted</code></a></p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/service/index.ts:7</p><hr><h3 id="rendered" tabindex="-1">rendered() <a class="header-anchor" href="#rendered" aria-label="Permalink to &quot;rendered()&quot;">​</a></h3><blockquote><p><strong>rendered</strong>(): <code>void</code></p></blockquote><p>Called when <code>std.render</code> is called.</p><h4 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><code>void</code></p><h4 id="inherited-from-3" tabindex="-1">Inherited from <a class="header-anchor" href="#inherited-from-3" aria-label="Permalink to &quot;Inherited from&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#rendered"><code>rendered</code></a></p><h4 id="defined-in-5" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-5" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/extension/lifecycle-watcher.ts:65</p><hr><h3 id="unmounted" tabindex="-1">unmounted() <a class="header-anchor" href="#unmounted" aria-label="Permalink to &quot;unmounted()&quot;">​</a></h3><blockquote><p><strong>unmounted</strong>(): <code>void</code></p></blockquote><p>Called when editor host is unmounted. Which means the editor host emit the <code>disconnectedCallback</code> lifecycle event.</p><h4 id="returns-4" tabindex="-1">Returns <a class="header-anchor" href="#returns-4" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><code>void</code></p><h4 id="overrides-2" tabindex="-1">Overrides <a class="header-anchor" href="#overrides-2" aria-label="Permalink to &quot;Overrides&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#unmounted"><code>unmounted</code></a></p><h4 id="defined-in-6" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-6" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/service/index.ts:15</p><hr><h3 id="setup" tabindex="-1">setup() <a class="header-anchor" href="#setup" aria-label="Permalink to &quot;setup()&quot;">​</a></h3><blockquote><p><code>static</code> <strong>setup</strong>(<code>di</code>): <code>void</code></p></blockquote><h4 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to &quot;Parameters&quot;">​</a></h4><h5 id="di" tabindex="-1">di <a class="header-anchor" href="#di" aria-label="Permalink to &quot;di&quot;">​</a></h5><p><code>Container</code></p><h4 id="returns-5" tabindex="-1">Returns <a class="header-anchor" href="#returns-5" aria-label="Permalink to &quot;Returns&quot;">​</a></h4><p><code>void</code></p><h4 id="inherited-from-4" tabindex="-1">Inherited from <a class="header-anchor" href="#inherited-from-4" aria-label="Permalink to &quot;Inherited from&quot;">​</a></h4><p><a href="./LifeCycleWatcher.html"><code>LifeCycleWatcher</code></a>.<a href="./LifeCycleWatcher.html#setup"><code>setup</code></a></p><h4 id="defined-in-7" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-7" aria-label="Permalink to &quot;Defined in&quot;">​</a></h4><p>packages/framework/block-std/src/extension/lifecycle-watcher.ts:34</p>`,87)]))}const p=a(o,[["render",d]]);export{f as __pageData,p as default};
