Deprecated
Use lambda.register()
function instead.
import { once } from "https://deno.land/x/denops_std@v4.0.0/anonymous/mod.ts";
Add oneshot anonymous functions as denops API and return the identifiers
import { Denops } from "../mod.ts";
import * as anonymous from "./mod.ts";
export async function main(denops: Denops): Promise<void> {
// Add anonymous functions
const ids = anonymous.once(
denops,
() => {
// Do what ever you want.
},
() => {
// Do what ever you want.
},
// You can add as many callbacks as you want...
);
// First calls complete normally
await denops.dispatch(denops.name, ids[0]);
await denops.dispatch(denops.name, ids[1]);
// But second call would throw errors
await denops.dispatch(denops.name, ids[0]);
}