Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple apps #43

Open
Domiii opened this issue Dec 17, 2016 · 4 comments
Open

Support multiple apps #43

Domiii opened this issue Dec 17, 2016 · 4 comments

Comments

@Domiii
Copy link
Contributor

Domiii commented Dec 17, 2016

Currently, the reduxReactFirebase call is very opinionated on how to use firebase, it attaches itself to the store as firebase and, in addition, also attaches itself to the global firebase module. That is bad style, and makes it entirely monolithic.

As explained in the official documentation, you can work against the database of a specific app by simply storing the reference to the object from the return value of the initializeApp call, and then call database() on that, instead of calling it directly on the default firebase object.

@RahavLussato
Copy link
Collaborator

I didn't understand what you suggest.
This lib is attached to firebase.database on the initialization and also give you access to the rest options by giving you the original firebase object.

If you want to do hacks of seperate the same app to multiple projects for not paying its not something that we need to support. Its breaks the idea of one project for one app/environment.
I don't familiar wirh situation that you need multiple projects on the same time for regular using.

@Domiii
Copy link
Contributor Author

Domiii commented Dec 17, 2016

Multi-project apps is a basic feature supported and advertised by firebase officially. This is neither hacking nor illegal nor is it unwelcome. For many of its products, Google tends to offer limitations per account, however the number of accounts is unlimited. That applies to Firebase, just like it does to Gmail and Drive. If they didn't want people to use multiple accounts, they would not make it such a core feature and they would limit accounts/apps/projects/whathaveyou per user. I myself am not even likely to exceed the limits of a single app's free plan with my prototype anytime soon, so I am not too worried. But in my front-end-only applications, I generally would like to be able to work against multiple back-ends at the same time.

Re my proposal: I was thinking along the lines of offering an additional parameter to determine the app, like so:

@firebase({
  app1: [
    'todos'
  ],
  app2: [
    'otherstuff'
  ]
})

and in render() you can do:

const { app1, app2, todos, otherstuff } = this.props;

This approach to global state management might not be the cleanest but it could work just fine for smaller apps. How to deal with complex "services" (such as firebase) in Redux is an open question, and is also discussed here and I opened a more specific discussion here (as well as other places).

However, if, as you say, there is some rationale that says that you only want an app to ever work against a single back-end, then that's of course unnecessary for your project, and you can safely ignore this issue :)

@RahavLussato
Copy link
Collaborator

Now after i saw the officially docs I understand you. Its not a common usage but it's something that can be too. It would be great if you can submit a PR for that.

@Domiii
Copy link
Contributor Author

Domiii commented Dec 17, 2016

I'll see where I can find the time :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants