/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ // @flow type Deferred = { promise: Promise, resolve: (arg: T) => mixed, reject: (arg: mixed) => mixed, }; export default function defer(): Deferred { let resolve = () => {}; let reject = () => {}; const promise = new Promise((_res, _rej) => { resolve = _res; reject = _rej; }); return { resolve, reject, promise }; }