How to use the zalgo-promise/src.ZalgoPromise.all function in zalgo-promise

To help you get started, we’ve selected a few zalgo-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / post-robot / src / drivers / receive / types.js View on Github external
try {
                // $FlowFixMe
                sendMessage(source, origin, {
                    type,
                    ack,
                    hash:   message.hash,
                    name:   message.name,
                    ...response
                }, { on, send });
            } catch (err) {
                throw new Error(`Send response message failed for ${ logName } in ${ getDomain() }\n\n${ stringifyError(err) }`);
            }
        }

        return ZalgoPromise.all([

            sendResponse(MESSAGE_TYPE.ACK),

            ZalgoPromise.try(() => {

                if (!options) {
                    throw new Error(`No handler found for post message: ${ message.name } from ${ origin } in ${ window.location.protocol }//${ window.location.host }${ window.location.pathname }`);
                }

                if (!matchDomain(options.domain, origin)) {
                    throw new Error(`Request origin ${ origin } does not match domain ${ options.domain.toString() }`);
                }

                const data = message.data;

                return options.handler({ source, origin, data });
github krakenjs / zoid / src / component / component.js View on Github external
export function destroyAll() : ZalgoPromise {
    if (bridge) {
        bridge.destroyBridges();
    }

    const results = [];

    const global = getGlobal();
    global.activeComponents = global.activeComponents || [];
    while (global.activeComponents.length) {
        results.push(global.activeComponents[0].destroy(new Error(`zoid destroyed all`), false));
    }

    return ZalgoPromise.all(results).then(noop);
}
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
ParentComponent.destroyAll = function destroyAll() {
        var results = [];

        while (ParentComponent.activeComponents.length) {
            results.push(ParentComponent.activeComponents[0].destroy());
        }

        return ZalgoPromise.all(results).then(noop);
    };
github krakenjs / post-robot / src / lib / promise.js View on Github external
export function promiseMap(items : Array, method : (item : T) => mixed | ZalgoPromise) : ZalgoPromise> {
    let results = [];
    for (let i = 0; i < items.length; i++) {
        results.push(ZalgoPromise.try(() => {
            return method(items[i]);
        }));
    }
    return ZalgoPromise.all(results);
}
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
tasks.openBridge = ZalgoPromise.all([tasks.open, tasks.buildUrl]).then(function (_ref4) {
                var proxyWin = _ref4[0],
                    url = _ref4[1];

                return _this2.openBridge(proxyWin, getDomainFromUrl(url), context);
            });

            tasks.loadUrl = ZalgoPromise.all([tasks.open, tasks.buildUrl, tasks.setWindowName]).then(function (_ref5) {
                var proxyWin = _ref5[0],
                    url = _ref5[1];

                return _this2.loadUrl(proxyWin, url);
            });

            tasks.switchPrerender = ZalgoPromise.all([tasks.prerender, _this2.onInit]).then(function () {
                return _this2.switchPrerender();
            });

            tasks.runTimeout = tasks.loadUrl.then(function () {
                return _this2.runTimeout();
            });

            return ZalgoPromise.hash(tasks);
        }).then(function () {
            return _this2.props.onEnter();
github paypal / paypal-smart-payment-buttons / src / button / pay.js View on Github external
.catch(err => {
                    return ZalgoPromise.all([
                        close(),
                        ZalgoPromise.reject(err)
                    ]);
                }).then(noop);
        });
github krakenjs / zoid / src / component / parent / index.js View on Github external
static destroyAll() : ZalgoPromise {
        let results = [];

        while (ParentComponent.activeComponents.length) {
            results.push(ParentComponent.activeComponents[0].destroy());
        }

        return ZalgoPromise.all(results).then(noop);
    }
}
github paypal / paypal-smart-payment-buttons / src / payment-flows / native.js View on Github external
const onApproveListener = socket.on(SOCKET_MESSAGE.ON_APPROVE, ({ data: { payerID, paymentID, billingToken } }) => {
            getLogger().info(`native_message_onapprove`).flush();
            const data = { payerID, paymentID, billingToken, forceRestAPI: true };
            const actions = { restart: () => fallbackToWebCheckout() };
            return ZalgoPromise.all([
                onApprove(data, actions),
                close()
            ]);
        });
github paypal / paypal-smart-payment-buttons / src / api / socket.js View on Github external
const close = () => {
        retry = false;

        requestListeners = {};
        errorListeners = [];

        for (const requestUID of Object.keys(responseListeners)) {
            const { listenerPromise } = responseListeners[requestUID];
            listenerPromise.asyncReject(new Error(`Socket closed`));
        }

        ZalgoPromise.all(activeRequests).then(() => {
            return socketPromise.then(
                socket => socket.close(),
                noop
            );
        });
    };
github paypal / paypal-smart-payment-buttons / src / menu / page.jsx View on Github external
return ZalgoPromise.delay(FADE_TIME).then(() => {
            setVisible(false);
            return ZalgoPromise.all([ onBlur(), hide() ]);
        });
    };