You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a project organized similarly to the example project, I've put rsf.js into a folder named rsf. Inside that folder, I've also put an index.js that dynamically import()s rsf.js at file scope. This system allows firebase and redux-saga-firebase to be in a separate bundle from the rest of the app for faster loading, which is important since firebase is huge and drops my mobile page speed score a lot.
// src/rsf/index.js
var p; //in case this code gets executed twice somehow
if(!p) p= import( /* webpackPreload: true */ "./rsf.js");
const prsf= (cb)=>p.then(cb);
export default prsf;
Imports of src/rsf in the sagas don't have to change, and the call sites can be transformed as follows:
// src/sagas/login.js (this is just a fragment of the file)
function* loginStatusWatcher() {
//const channel = yield call(rsf.auth.channel); //original
const channel = yield call(()=>prsf(({rsf})=>rsf.auth.channel)); //call unwraps promise
while (true) {
const r = yield take(channel);
console.log("loginStatusWatcher",r); // log result r to console
if (r && r.user) yield put(actions.loginSuccess(r.user));
else yield put(actions.logoutSuccess()); // this line triggers logout... not important
}
}
The thing I can't figure out is, this saga no longer works after the change. Instead of r being a user object, it is now always the last action object before the login status change. For example, when the app is first loaded, the last action is to check some messages from another channel. So, the result r is the messages action object, which is absolutely mind boggling. Later, if the user attempts to sign in anonymously, the console log shows r to be the login action object, not the user object. Screenshot below. I assume the promise has confused redux-saga, redux-saga-firebase, or perhaps just myself (quite possible since I'm a total newbie). Do you know how to get out of this but keep the separate firebase bundle? Any idea what might be causing it? I filed an issue here because other channels whose call sites have been similarly transformed to use prsf, such as the messages channel, are returning the expected QuerySnapshot object.
The text was updated successfully, but these errors were encountered:
In a project organized similarly to the example project, I've put
rsf.js
into a folder named rsf. Inside that folder, I've also put anindex.js
that dynamicallyimport()
srsf.js
at file scope. This system allows firebase and redux-saga-firebase to be in a separate bundle from the rest of the app for faster loading, which is important since firebase is huge and drops my mobile page speed score a lot.Imports of
src/rsf
in the sagas don't have to change, and the call sites can be transformed as follows:The thing I can't figure out is, this saga no longer works after the change. Instead of
r
being a user object, it is now always the last action object before the login status change. For example, when the app is first loaded, the last action is to check some messages from another channel. So, the result r is the messages action object, which is absolutely mind boggling. Later, if the user attempts to sign in anonymously, the console log shows r to be the login action object, not the user object. Screenshot below. I assume the promise has confused redux-saga, redux-saga-firebase, or perhaps just myself (quite possible since I'm a total newbie). Do you know how to get out of this but keep the separate firebase bundle? Any idea what might be causing it? I filed an issue here because other channels whose call sites have been similarly transformed to useprsf
, such as the messages channel, are returning the expectedQuerySnapshot
object.The text was updated successfully, but these errors were encountered: