From 260084ccbf053485d00d5b6ebc804252c409be49 Mon Sep 17 00:00:00 2001 From: Gudmund Vatn Date: Fri, 17 Apr 2020 12:51:10 +0200 Subject: Add close method to Plugin (#4670) (#4785) --- cli/js/plugins.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cli/js/plugins.ts') diff --git a/cli/js/plugins.ts b/cli/js/plugins.ts index 3fe0574ca..498da8e16 100644 --- a/cli/js/plugins.ts +++ b/cli/js/plugins.ts @@ -1,5 +1,6 @@ import { openPlugin as openPluginOp } from "./ops/plugins.ts"; import { core } from "./core.ts"; +import { close } from "./ops/resources.ts"; export interface AsyncHandler { (msg: Uint8Array): void; @@ -32,18 +33,17 @@ class PluginOpImpl implements PluginOp { } } -// TODO(afinch7): add close method. - interface Plugin { ops: { [name: string]: PluginOp; }; + close(): void; } class PluginImpl implements Plugin { #ops: { [name: string]: PluginOp } = {}; - constructor(_rid: number, ops: { [name: string]: number }) { + constructor(readonly rid: number, ops: { [name: string]: number }) { for (const op in ops) { this.#ops[op] = new PluginOpImpl(ops[op]); } @@ -52,6 +52,10 @@ class PluginImpl implements Plugin { get ops(): { [name: string]: PluginOp } { return Object.assign({}, this.#ops); } + + close(): void { + close(this.rid); + } } export function openPlugin(filename: string): Plugin { -- cgit v1.2.3