Skip to main content
Module

x/denops_std/anonymous/mod.ts>once

📚 Standard module for denops.vim
Go to Latest
function once
Deprecated
Deprecated

Use lambda.register() function instead.

import { once } from "https://deno.land/x/denops_std@v4.1.2/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]);
}

Type Parameters

N extends number

Parameters

denops: Denops
...callbacks: Callback[] & { length: N; }