title: Change a JavaScript export based on event
body: <p>I'm using react-admin. I have <code>firebase.js</code>, which exports a data provider and an auth provider. Right now <code>firebase.js</code> looks something like</p>
  <pre><code>export const authProvider = MyCustomAuthProvider(...)
  export const dataProvider = FirebaseDataProvider(..., {rootRef: &quot;users/[authProvider.get~this~user().email]&quot;)
  </code></pre>
  <p>But I'd like the <code>dataProvider</code> imported to change when the user logs in / out (the reason being that the data provider has as its root collection at 'users/[user email]'). That's actually why I stopped using the <code>FirebaseAuthProvider</code> blackbox, because I figured I could use the login/logout functions to trigger changing the dataProvider.</p>
  <p>What's the best way to accomplish this? Just declare the dataProvider using
  <code>let dataProvider = null</code> and every time a user logs in/out, set that variable. And then add a function to the auth provider that returns that variable? There seems to be a more elegant way, but I'm not as experienced in JavaScript unfortunately.</p>
  <p>Also for reference, the reason I'm taking this approach instead of just creating a dataProvider with rootRef 'users' and then accessing the correct collection / document when I want to view or modify data is because FirebaseDataProvider is a bit of black box and doesn't allow me to do that (unless I'm missing something). If I could get this all to work with FirebaseDataProvider, it <em>has</em> saved me a ton of time so that would be great.</p>