UNPKG

416 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3
4/**
5 * @name nextTick
6 * @description Defer the operation to the queue for evaluation on the next tick
7 */
8export function nextTick(onExec, onError) {
9 Promise.resolve().then(() => {
10 onExec();
11 }).catch(error => {
12 if (onError) {
13 onError(error);
14 } else {
15 console.error(error);
16 }
17 });
18}
\No newline at end of file