DefinitelyTyped/types/flushable/flushable-tests.ts

21 lines
469 B
TypeScript

/**
* The usage example is taken directly
* from the package's README
*/
import flushable from 'flushable';
// prints a message to the console after 1 second
const operation = flushable(flushed => {
const result = `I completed ${flushed ? 'early' : 'on time'}`;
}, 1000);
// true if the callback has not been executed
operation.pending();
// stops the callback from being executed
operation.cancel();
// immediately executes the callback
operation.flush();