Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "promise/timeout"

Index

Interfaces

Variables

Variables

Const timeout

timeout: PromiseTimeoutFunction = promiseTimeoutInitializer

Promise Timeout

Returns a promise which resolves after given time


Example:

import { timeout } from "@thalesrc/js-utils/promise";

timeout(1000);
 .then(() => console.log("will be logged after a second"));

Example with a resolve value:

import { timeout } from "@thalesrc/js-utils/promise";

timeout(1000, "foo");
 .then(val => console.log("will log 'foo' after a second", val));

Can be used in promise chaining:

import { timeout } from "@thalesrc/js-utils/promise";

fetch("http://localhost:8080/anEndpoint") // Fetch something
 .then(val => timeout(1000, val)) // Wait a second after response
 .then(val => {
   ...do something else
 });

Static usage example:

import "@thalesrc/js-utils/promise/static/timeout";

Promise.timeout(1000);
 .then(() => console.log("will be logged after a second"));

see

PromiseTimeoutFunction#cancel for cancelling

Generated using TypeDoc