S
SolidJS16mo ago
tourist

on store change

is it possible to run a function after a store value has been changed?
const Main = () => {
const app = useFirebaseApp();
const auth = getAuth(app);
const state = useAuth(auth);
const db = getFirestore(app);

let todos = null;
createEffect(on(state, () => {
if (!state.loading && state.data !== null) {
todos = useFirestore(doc(db, "todos", state.data?.uid));
}
}));
const Main = () => {
const app = useFirebaseApp();
const auth = getAuth(app);
const state = useAuth(auth);
const db = getFirestore(app);

let todos = null;
createEffect(on(state, () => {
if (!state.loading && state.data !== null) {
todos = useFirestore(doc(db, "todos", state.data?.uid));
}
}));
i want to access the document todos/uid but the uid will only exist after firebase resolves whether the user is currently logged in and what i have here is sort of what i'm looking for except on( expects a reactive value
3 Replies
thetarnav
thetarnav16mo ago
remove on and it will work
tourist
touristOP16mo ago
i did try that but it didn't end up working because useFirestore is a hook and there was a warning about it not being used since it wasn't in a render() or something related to that. I did manage to solve it using createMemo, but I ran into a new issue that i posted in #support regarding its use (https://discord.com/channels/722131463138705510/1135814148383588442)
Want results from more Discord servers?
Add your server