Skip to content

Commit

Permalink
Allow usertransformfailsafe more time & override
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Oaklyn committed Mar 16, 2020
1 parent 966f88a commit 794a8fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/vue-user-plugin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Promise from "bluebird";

const MAX_TRANSFORM_WAIT = 1000 * 6;
const MAX_TRANSFORM_WAIT = 1000 * 10;
const UserTransformFailsafe = {
timeout: null,
pendingPromise: null,
time: MAX_TRANSFORM_WAIT,
newUnresolvedError() {
return new Error("User Transformation Timed Out. The User Transform promise passed to VueUserPlugin did not resolve or rejected")
},
Expand All @@ -12,7 +13,7 @@ const UserTransformFailsafe = {
return new Promise((resolve, reject) => {
this.timeout = setTimeout(() => {
reject(this.newUnresolvedError());
}, MAX_TRANSFORM_WAIT);
}, UserTransformFailsafe.time);
});
},
start(transformPromise) {
Expand Down Expand Up @@ -78,9 +79,9 @@ export const VueUserPlugin = {
* @param {*} Vue
* @param {*} options - auth, transformer; where the transformer function transforms Firebase's user object
*/
install: function(Vue, {auth, transformer}) {
install: function(Vue, {auth, transformer, timeout}) {
var plugin = this;

UserTransformFailsafe.time = timeout || MAX_TRANSFORM_WAIT;

auth.onAuthStateChanged((user) => {
if(user) {
Expand Down

0 comments on commit 794a8fa

Please sign in to comment.