diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-06-28 14:39:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 14:39:43 -0400 |
commit | f2345b7d1c035422dad553a4541ee486d952afa9 (patch) | |
tree | a13d87b874b28b1be9cfe8e343cb37c780107883 /ext/mixed/js/api.js | |
parent | 7b5dd5c310f7ec4d7f6e329367d34258cce10e8e (diff) |
Use deferPromise (#630)
* Use deferPromise
* Move definition
* Implement promiseTimeout using deferPromise
Diffstat (limited to 'ext/mixed/js/api.js')
-rw-r--r-- | ext/mixed/js/api.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 5c17d50e..1e421147 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -212,12 +212,11 @@ const api = (() => { _createActionPort(timeout=5000) { return new Promise((resolve, reject) => { let timer = null; - let portNameResolve; - let portNameReject; - const portNamePromise = new Promise((resolve2, reject2) => { - portNameResolve = resolve2; - portNameReject = reject2; - }); + const { + promise: portNamePromise, + resolve: portNameResolve, + reject: portNameReject + } = deferPromise(); const onConnect = async (port) => { try { |