How to use the zalgo-promise/src.ZalgoPromise.try 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 paypal / paypal-smart-payment-buttons / test / client / happy.js View on Github external
window.xprops.createOrder = mockAsyncProp(expect('createOrder', async () => {
                return ZalgoPromise.try(() => {
                    return orderID;
                });
            }));
github krakenjs / zoid / src / component / parent / index.js View on Github external
tryInit(method : () => mixed) : ZalgoPromise> {
        return ZalgoPromise.try(method).catch(err => {
            this.onInit.reject(err);
        }).then(() => {
            return this.onInit;
        });
    }
github paypal / paypal-smart-payment-buttons / src / button / button.js View on Github external
function initiatePayment({ payment } : { payment : Payment }) : ZalgoPromise {
        return ZalgoPromise.try(() => {
            if (paymentProcessing) {
                return;
            }

            props = getProps({ facilitatorAccessToken });

            const { win, fundingSource } = payment;
            const { onClick } = props;

            if (onClick) {
                onClick({ fundingSource });
            }

            if (isEnabled()) {
                paymentProcessing = true;
github krakenjs / zoid / src / parent / index.js View on Github external
openPrerenderFrame() : ZalgoPromise> {
        return ZalgoPromise.try(() => {
            if (this.driver.openPrerenderFrame) {
                return this.driver.openPrerenderFrame.call(this);
            }
        });
    }
github krakenjs / post-robot / src / public / send.js View on Github external
function normalizeDomain(win : CrossDomainWindowType, targetDomain : DomainMatcher, actualDomain : ?string, { send } : { send : SendType }) : ZalgoPromise> {
    if (typeof targetDomain === 'string') {
        return ZalgoPromise.resolve(targetDomain);
    }
    
    return ZalgoPromise.try(() => {
        return actualDomain || sayHello(win, { send }).then(({ domain }) => domain);

    }).then(normalizedDomain => {
        if (!matchDomain(targetDomain, targetDomain)) {
            throw new Error(`Domain ${ stringify(targetDomain) } does not match ${ stringify(targetDomain) }`);
        }

        return normalizedDomain;
    });
}
github krakenjs / zoid / src / parent / index.js View on Github external
render(target : CrossDomainWindowType, container : string | HTMLElement, context : $Values) : ZalgoPromise {
        return ZalgoPromise.try(() => {
            this.component.log(`render`);

            this.driver = RENDER_DRIVERS[context];
            const uid = `${ ZOID }-${ this.component.tag }-${ uniqueID() }`;
            const domain = this.getDomain();
            const childDomain = this.getChildDomain();
            
            this.component.checkAllowRender(target, domain, container);

            if (target !== window) {
                this.delegate(context, target);
            }

            const windowProp = this.props.window;

            const init = this.initPromise;
github paypal / paypal-smart-payment-buttons / src / flows / checkout.js View on Github external
const onCancel = once(() => {
        return ZalgoPromise.try(() => {
            if (approved) {
                return false;
            }

            return validationPromise;

        }).then(valid => {

            if (!valid) {
                return;
            }
            
            return createOrder().then(orderID => {
                return window.xprops.onCancel({ orderID });
            }).catch(err => {
                return window.xprops.onError(err);
github krakenjs / zoid / src / component / parent / index.js View on Github external
showComponent() : ZalgoPromise {
        return ZalgoPromise.try(() => {
            if (this.props.onDisplay) {
                return this.props.onDisplay();
            }
        }).then(() => {
            if (this.element) {
                return showAndAnimate(this.element, ANIMATION_NAMES.SHOW_COMPONENT, this.clean.register);
            }
        });
    }
github krakenjs / zoid / src / parent / index.js View on Github external
runTimeout() : ZalgoPromise {
        return ZalgoPromise.try(() => {
            const timeout = this.props.timeout;

            if (timeout) {
                return this.initPromise.timeout(timeout, new Error(`Loading component timed out after ${ timeout } milliseconds`));
            }
        });
    }