function createSession (params) { console.log('creating session...'); return new Promise((resolve, reject) => { livePricing.api.createSession(params) .then((response) => { if (response.status !== 201) { console.error(response.status, 'something went wrong...') return response.json() .then(console.error); } else { // session created _.delay(() => { resolve({ location: response.headers.get('location'), response: response.json() }); }, pollDelay); } }) .catch(reject); }); }
_.delay(() => { poll(pollState); }, pollDelay);
this._startContainer, this._getContainerInfo, (container, next) => _.delay(next, this.initialDelayMs, null, container), this._registerContainer, ].map( stage => stage.bind(this) );