Skip to content

Commit edcadd4

Browse files
authored
Merge pull request #9 from vim-denops/plugin-dispose
👍 add `AsyncDisposable` to the return type of `Entrypoint`
2 parents 42e53eb + a0b9aef commit edcadd4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

denops.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export interface Denops {
147147
/**
148148
* Denops's entrypoint definition.
149149
*
150-
* Use this type to ensure the `main` function is properly implemented like
150+
* Use this type to ensure the `main` function is properly implemented like:
151151
*
152152
* ```ts
153153
* import type { Entrypoint } from "https://deno.land/x/denops_core@$MODULE_VERSION/mod.ts";
@@ -156,5 +156,23 @@ export interface Denops {
156156
* // ...
157157
* }
158158
* ```
159+
*
160+
* If an `AsyncDisposable` object is returned, resources can be disposed of
161+
* asynchronously when the plugin is unloaded, like:
162+
*
163+
* ```ts
164+
* import type { Entrypoint } from "https://deno.land/x/denops_core@$MODULE_VERSION/mod.ts";
165+
*
166+
* export const main: Entrypoint = (denops) => {
167+
* // ...
168+
* return {
169+
* [Symbol.asyncDispose]: async () => {
170+
* // Dispose resources...
171+
* }
172+
* }
173+
* }
174+
* ```
159175
*/
160-
export type Entrypoint = (denops: Denops) => void | Promise<void>;
176+
export type Entrypoint = (
177+
denops: Denops,
178+
) => void | AsyncDisposable | Promise<void | AsyncDisposable>;

0 commit comments

Comments
 (0)