@lighthouse/sdk
Advanced tools
Comparing version 8.0.0-beta-6 to 8.0.0-beta-7
@@ -89,24 +89,12 @@ 'use strict'; | ||
// application Id and then fire the registration request for that | ||
return deregister().then(function () { | ||
return deregister().catch(function (error) { | ||
throw new Error('MessagesDeregistrationError'); | ||
}).then(function () { | ||
return next(action); | ||
}).then(function (result) { | ||
return register().catch(function (error) { | ||
// TODO fire errors via logs module | ||
if (console) console.error(error); | ||
}).reflect().then(function () { | ||
return register().then(function () { | ||
return _bluebird2.default.resolve(result); | ||
}) | ||
// NOTE So things get a little bit weird here, but the concept is fairly | ||
// simple. For the action we're firing (e.g) login, we want to wait for | ||
// the messages registration request to finish before it resolves. But | ||
// we don't want it to error if the registration fails, because that | ||
// shouldn't hold up login or any other action we're watching in this | ||
// middleware. So we use Bluebirds `reflect` to do that and resolve the | ||
// result of original action | ||
// NOTE it's important we resolve the result of the action we're catching | ||
// (basically the result of `next(action)`) and not the registration result | ||
; | ||
}).catch(function (error) { | ||
// TODO fire errors via logs module | ||
if (console) console.error(error); | ||
}).catch(function (error) { | ||
throw new Error('MessagesRegistrationError'); | ||
}); | ||
}); | ||
@@ -113,0 +101,0 @@ }; |
{ | ||
"name": "@lighthouse/sdk", | ||
"version": "8.0.0-beta-6", | ||
"version": "8.0.0-beta-7", | ||
"description": "Lighthouse.io SDK for JavaScript applications", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
397808
5435