main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
327 bytes
|
Line | |
---|
1 | // @flow
|
---|
2 |
|
---|
3 | export default function debounce<T>(fn: Function): () => Promise<T> {
|
---|
4 | let pending;
|
---|
5 | return () => {
|
---|
6 | if (!pending) {
|
---|
7 | pending = new Promise<T>(resolve => {
|
---|
8 | Promise.resolve().then(() => {
|
---|
9 | pending = undefined;
|
---|
10 | resolve(fn());
|
---|
11 | });
|
---|
12 | });
|
---|
13 | }
|
---|
14 |
|
---|
15 | return pending;
|
---|
16 | };
|
---|
17 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.