Closed SrBrahma closed 3 years ago
Yeah that's super easy to do. I usually have an Auth
helper class that listens to auth changes and sets an observable accordingly. You can then use that observable in your document source function (which should return a ref or a field-path), which then automatically updates the document ref when your auth changes.
import { Document } from 'firestorter';
import { Auth } from './Auth';
const doc = new Document(() => Auth.getInstance().user ? `mycollection/${Auth.getInstance().userId}` : null);
I am considering using this lib, instead of doing the mobx by hand.
But, lets say that I, an User, just logged in. I want my ref to be set to my users/uid. But what to do when I logout and login, changing user uid? How to handle both cases, specially when the user is no longer logged?