Skip to content

Commit ce936c9

Browse files
committed
2 parents 51fc305 + 3e41c91 commit ce936c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+8541
-4074
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}]
1010
],
1111
"plugins": [
12-
["lodash", { "id": ["lodash"]}],
12+
"lodash",
1313
"add-module-exports",
1414
"transform-object-rest-spread",
1515
"transform-object-assign",

.eslintrc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ root: true
22

33
parser: babel-eslint
44

5-
extends: [standard, standard-react]
6-
plugins: [babel, react]
5+
extends: [standard, standard-react, prettier, prettier/react]
6+
plugins: [babel, react, prettier]
77

88
env:
99
browser: true
@@ -14,3 +14,13 @@ env:
1414
rules:
1515
semi: [2, 'never']
1616
no-console: 'error'
17+
prettier/prettier: ['error', {
18+
singleQuote: true,
19+
trailingComma: 'es6',
20+
semi: false,
21+
bracketSpacing: true,
22+
jsxBracketSameLine: true,
23+
printWidth: 80,
24+
tabWidth: 2,
25+
useTabs: false
26+
}]

README.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@
1919
The [Material Example](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete/material) is deployed to [demo.react-redux-firebase.com](https://demo.react-redux-firebase.com).
2020

2121
## Features
22-
- Support for updating and nested props
23-
- [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
22+
- Integrated into redux
2423
- Out of the box support for authentication (with auto load user profile)
25-
- Firebase Database, Firestore, Auth, Storage, and Messaging Support
24+
- Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
25+
- Automatic binding/unbinding of listeners through React Higher Order Components (`firebaseConnect` and `firestoreConnect`)
26+
- [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
2627
- Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
27-
- queries including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
28-
- Automatic binding/unbinding through `firestoreConnect` (manual through `watchEvent`)
29-
- Declarative decorator syntax for React components
30-
- Tons of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
31-
- Action Types and other Constants exported for external use (such as in `redux-observable`)
32-
- Firebase v3+ support
28+
- Multiple queries types supported including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
29+
- Tons of examples of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
3330
- Server Side Rendering Support
3431
- [`react-native` support](/docs/recipes/react-native.md) using [native modules](http://docs.react-redux-firebase.com/history/v2.0.0/docs/recipes/react-native.html#native-modules) or [web sdk](/docs/recipes/react-native.md#jsweb)
3532

3633
## Install
3734

3835
```bash
39-
npm install --save react-redux-firebase@next
36+
npm install --save react-redux-firebase
4037
```
4138

4239
## Use
4340

44-
Include `reactReduxFirebase` in your store compose function and `firebaseReducer` in your reducers:
41+
Include `reactReduxFirebase` (store enhancer) and `firebaseReducer` (reducer) while creating your redux store:
4542

4643
```javascript
44+
import React from 'react'
45+
import { render } from 'react-dom'
46+
import { Provider } from 'react-redux'
4747
import { createStore, combineReducers, compose } from 'redux'
4848
import { reactReduxFirebase, firebaseReducer } from 'react-redux-firebase'
4949
import firebase from 'firebase'
@@ -63,13 +63,13 @@ firebase.initializeApp(config) // <- new to v2.*.*
6363
// initialize firestore
6464
// firebase.firestore() // <- needed if using firestore
6565

66-
// Add reduxReduxFirebase enhancer when making store creator
66+
// Add reactReduxFirebase enhancer when making store creator
6767
const createStoreWithFirebase = compose(
6868
reactReduxFirebase(firebase, rrfConfig), // firebase instance as first argument
6969
// reduxFirestore(firebase) // <- needed if using firestore
7070
)(createStore)
7171

72-
// Add Firebase to reducers
72+
// Add firebase to reducers
7373
const rootReducer = combineReducers({
7474
firebase: firebaseReducer,
7575
// firestore: firestoreReducer // <- needed if using firestore
@@ -78,9 +78,18 @@ const rootReducer = combineReducers({
7878
// Create store with reducers and initial state
7979
const initialState = {}
8080
const store = createStoreWithFirebase(rootReducer, initialState)
81+
82+
// Setup react-redux so that connect HOC can be used
83+
const App = () => (
84+
<Provider store={store}>
85+
<Todos />
86+
</Provider>
87+
);
88+
89+
render(<App/>, document.getElementById('root'));
8190
```
8291

83-
In components:
92+
The Firebase instance can then be grabbed from context within your components (`withFirebase` and `firebaseConnect` Higher Order Components provided to help):
8493

8594
**Add Data**
8695

@@ -110,7 +119,7 @@ export default withFirebase(Todos)
110119
// or firebaseConnect()(Todos) if attaching listeners
111120
```
112121

113-
**Load Data (listeners managed on mount/unmount)**
122+
**Load Data (listeners automatically managed on mount/unmount)**
114123

115124
```jsx
116125
import React from 'react'
@@ -170,7 +179,7 @@ import { firebaseConnect, getVal } from 'react-redux-firebase'
170179

171180
// Component enhancer that loads todo into redux then into the todo prop
172181
const enhance = compose(
173-
firebaseConnect((props) => [
182+
firebaseConnect((props) => {
174183
// Set listeners based on props (prop is route parameter from react-router in this case)
175184
return [
176185
{ path: `todos/${props.params.todoId}` }, // create todo listener
@@ -241,7 +250,6 @@ export default compose(
241250
)(Todos)
242251
```
243252

244-
245253
## [Docs](http://react-redux-firebase.com)
246254
See full documentation at [react-redux-firebase.com](http://react-redux-firebase.com)
247255

@@ -280,15 +288,23 @@ Join us on the [redux-firebase gitter](https://gitter.im/redux-firebase/Lobby).
280288

281289
View docs for recipes on integrations with:
282290

283-
* [redux-firestore](/docs/firestore.md)
284-
* [redux-thunk](/docs/integrations/thunks.md)
285-
* [redux-observable](/docs/integrations/epics.md)
286-
* [redux-saga](/docs/integrations/redux-saga.md)
287-
* [redux-form](/docs/integrations/redux-form.md)
288-
* [redux-auth-wrapper](/docs/integrations/routing.md#advanced)
289-
* [redux-persist](/docs/integrations/redux-persist.md) - [improved integration with `v2.0.0`](http://docs.react-redux-firebase.com/history/v2.0.0/docs/integrations/redux-persist.html)
291+
* [redux-firestore](http://react-redux-firebase.com/docs/firestore.md)
292+
* [redux-thunk](http://react-redux-firebase.com/docs/integrations/thunks.md)
293+
* [redux-observable](http://react-redux-firebase.com/docs/integrations/epics.md)
294+
* [redux-saga](http://react-redux-firebase.com/docs/integrations/redux-saga.md)
295+
* [redux-form](http://react-redux-firebase.com/docs/integrations/redux-form.md)
296+
* [redux-auth-wrapper](http://react-redux-firebase.com/docs/integrations/routing.md#advanced)
297+
* [redux-persist](http://react-redux-firebase.com/docs/integrations/redux-persist.md) - [improved integration with `v2.0.0`](http://react-redux-firebase.com/docs/integrations/redux-persist.html)
290298
* [react-native](/docs/integrations/react-native.md)
291-
* [react-native-firebase](http://docs.react-redux-firebase.com/history/v2.0.0/docs/integrations/react-native.html#native-modules) - requires `v2.0.0`
299+
* [react-native-firebase](http://react-redux-firebase.com/docs/integrations/react-native.html#native-modules) - requires `v2.0.0`
300+
301+
## Firestore
302+
303+
If you plan to use Firestore, you should checkout [`redux-firestore`][redux-firestore]. It integrates nicely with `react-redux-firebase` (v2 only) and it allows you to run Real Time Database and Firestore along side each other.
304+
305+
`react-redux-firebase` provides the `firestoreConnect` HOC (similar to `firebaseConnect`) for easy setting/unsetting of listeners.
306+
307+
Currently `react-redux-firebase` still handles auth when using [`redux-firestore`][redux-firestore] - The future plan is to also have auth standalone auth library that will allow the developer to choose which pieces they do/do not want.
292308

293309
## Starting A Project
294310

@@ -308,7 +324,7 @@ Please visit the [FAQ section of the docs](http://docs.react-redux-firebase.com/
308324

309325
This project exists thanks to all the people who contribute.
310326

311-
<a href="graphs/contributors"><img src="https://opencollective.com/react-redux-firebase/contributors.svg?width=890" /></a>
327+
<a href="https://github.com/prescottprue/react-redux-firebase/graphs/contributors"><img src="https://opencollective.com/react-redux-firebase/contributors.svg?width=890" /></a>
312328

313329
## Backers
314330

@@ -337,3 +353,4 @@ Thank you to all our backers! 🙏
337353
[code-style-url]: http://standardjs.com/
338354
[gitter-image]: https://img.shields.io/gitter/room/redux-firebase/gitter.svg?style=flat-square
339355
[gitter-url]: https://gitter.im/redux-firebase/Lobby
356+
[redux-firestore]: https://github.com/prescottprue/redux-firestore

SUMMARY.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@
3131
* [withFirebase](/docs/api/withFirebase.md)
3232
* [firestoreConnect](/docs/api/firestoreConnect.md)
3333
* [withFirestore](/docs/api/withFirestore.md)
34-
* [firebaseStateReducer](/docs/api/reducer.md)
34+
* [firebaseReducer](/docs/api/reducer.md)
35+
* [isInitializingReducer](/docs/api/reducers.md#isinitializingreducer)
36+
* [requestingReducer](/docs/api/reducers.md#requestingreducer)
37+
* [requestedReducer](/docs/api/reducers.md#requestedreducer)
38+
* [timestampsReducer](/docs/api/reducers.md#timestampsreducer)
39+
* [authReducer](/docs/api/reducers.md#authreducer)
40+
* [authErrorReducer](/docs/api/reducers.md#autherrorreducer)
41+
* [profileReducer](/docs/api/reducers.md#profilereducer)
42+
* [errorsReducer](/docs/api/reducers.md#errorsreducer)
43+
* [listenersTeducer](/docs/api/reducers.md#listenersreducer)
44+
* [dataReducer](/docs/api/reducers.md#datareducer)
45+
* [orderedReducer](/docs/api/reducers.md#orderedreducer)
3546
* [reactReduxFirebase](/docs/api/enhancer.md)
3647
* [props.firebase](/docs/api/props-firebase.md)
3748
* [getFirebase](/docs/api/get-firebase.md)

bin/api-docs-generate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const files = [
2828
src: 'helpers.js',
2929
dest: 'helpers.md'
3030
},
31+
{
32+
src: 'reducers.js',
33+
dest: 'reducers.md'
34+
},
3135
{
3236
src: 'reducer.js',
3337
dest: 'reducer.md'

book.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
"gitbookConfigURL": "https://raw.githubusercontent.com/prescottprue/react-redux-firebase/master/book.json",
2323
"options": [
2424
{
25-
"value": "http://docs.react-redux-firebase.com/history/v1.4.0/",
26-
"text": "Version 1.4.0"
25+
"value": "http://docs.react-redux-firebase.com/history/v2.0.0/",
26+
"text": "Version 2.0.0",
27+
"selected": true
2728
},
2829
{
2930
"value": "http://docs.react-redux-firebase.com/history/v1.5.0/",
30-
"text": "Version 1.5.0",
31-
"selected": true
31+
"text": "Version 1.5.0"
3232
},
3333
{
34-
"value": "http://docs.react-redux-firebase.com/history/v2.0.0/",
35-
"text": "Version 2.0.0"
34+
"value": "http://docs.react-redux-firebase.com/history/v1.4.0/",
35+
"text": "Version 1.4.0"
3636
}
3737
]
3838
}

docs/FAQ.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* [Complete Firebase Auth Integration](http://react-redux-firebase.com/docs/auth.html#examples) including `signInWithRedirect` compatibility for OAuth Providers
1717

1818
#### Well why not combine?
19-
I have been talking to the author of [redux-react-firebase](https://github.com/tiberiuc/redux-react-firebase) about combining, but we are not sure that the users of both want that at this point. Join us on the [redux-firebase gitter](https://gitter.im/redux-firebase/Lobby) if you haven't already since a ton of this type of discussion goes on there.
19+
I have been talking to the author of [redux-react-firebase](https://github.com/tiberiuc/redux-react-firebase) about combining, but we are not sure that the users of both want that at this point. Join us on the [redux-firebase gitter][gitter-url] if you haven't already since a ton of this type of discussion goes on there.
2020

2121
#### What about [redux-firebase](https://github.com/colbyr/redux-firebase)?
2222
The author of [redux-firebase](https://github.com/colbyr/redux-firebase) has agreed to share the npm namespace! Currently the plan is to take the framework agnostic redux core logic of `react-redux-firebase` and [place it into `redux-firebase`](https://github.com/prescottprue/redux-firebase)). Eventually `react-redux-firebase` and potentially other framework libraries can depend on that core (the new `redux-firebase`).
@@ -34,8 +34,14 @@
3434

3535
![data flow](/docs/static/dataFlow.png)
3636

37-
5. How do I help?
37+
5. Where is the `yarn.lock` file?
38+
39+
There isn't one, there is just a `package-lock.json`. `npm v5.x.x` adds support for a `package-lock.json` file which serves a similar purpose to a `yarn.lock` file. Instead of managing multiple lock files, the single `package-lock.json` contains exact version information for dependencies.
40+
41+
6. How do I help?
3842

3943
* Join the conversion on [gitter][gitter-url]
4044
* Post Issues
4145
* Create Pull Requests
46+
47+
[gitter-url]: gitter.im/redux-firebase/Lobby

docs/api/compose.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+
### Table of Contents
4+
5+
- [reactReduxFirebase](#reactreduxfirebase)
6+
7+
## reactReduxFirebase
8+
9+
Middleware that handles configuration (placed in redux's
10+
`compose` call)
11+
12+
**Parameters**
13+
14+
- `fbConfig` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Firebase config including databaseURL
15+
- `fbConfig.apiKey` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase apiKey
16+
- `fbConfig.authDomain` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase auth domain
17+
- `fbConfig.databaseURL` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase database url
18+
- `fbConfig.storageBucket` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase storage bucket
19+
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific config
20+
such as userProfile
21+
- `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user
22+
profiles
23+
- `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable Firebase
24+
database logging
25+
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update
26+
profile when logging in. (default: `false`)
27+
- `config.resetBeforeLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to empty profile
28+
and auth state on login
29+
- `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable
30+
auth redirect handling listener. (default: `true`)
31+
- `config.onAuthStateChanged` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when auth state
32+
changes. Argument Pattern: `(authData, firebase, dispatch)`
33+
- `config.enableEmptyAuthChanges` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable
34+
empty auth changes. When set to true, `onAuthStateChanged` will be fired with,
35+
empty auth changes such as undefined on initialization. See
36+
[#137](https://github.com/prescottprue/react-redux-firebase/issues/137) for
37+
more details. (default: `false`)
38+
- `config.onRedirectResult` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when redirect
39+
result is returned. Argument Pattern: `(authData, firebase, dispatch)`
40+
- `config.customAuthParameters` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object for setting which
41+
customAuthParameters are passed to external auth providers.
42+
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user
43+
profile is saved.
44+
- `config.fileMetadataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying
45+
how file meta data is written during file uploads
46+
- `config.profileParamsToPopulate` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** Parameters within
47+
profile object to populate
48+
- `config.autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to
49+
automatically populate profile with data loaded through
50+
profileParamsToPopulate config. (default: `true`)
51+
- `config.setProfilePopulateResults` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to
52+
call SET actions for data that results from populating profile to redux under
53+
the data path. For example role parameter on profile populated from 'roles'
54+
root. True will call SET_PROFILE as well as a SET action with the role that
55+
is loaded (places it in data/roles). (default: `false`)
56+
57+
**Examples**
58+
59+
_Setup_
60+
61+
```javascript
62+
import { createStore, compose } from 'redux'
63+
import { reactReduxFirebase } from 'react-redux-firebase'
64+
65+
// React Redux Firebase Config
66+
const config = {
67+
userProfile: 'users', // saves user profiles to '/users' on Firebase
68+
// here is where you place other config options
69+
}
70+
71+
// Add react-redux-firebase to compose
72+
// Note: In full projects this will often be within createStore.js or store.js
73+
const createStoreWithFirebase = compose(
74+
reactReduxFirebase(fbConfig, config),
75+
)(createStore)
76+
77+
// Use Function later to create store
78+
const store = createStoreWithFirebase(rootReducer, initialState)
79+
```
80+
81+
_Custom Auth Parameters_
82+
83+
```javascript
84+
// Follow Setup example with the following config:
85+
const config = {
86+
customAuthParameters: {
87+
google: {
88+
// prompts user to select account on every google login
89+
prompt: 'select_account'
90+
}
91+
}
92+
}
93+
```
94+
95+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component and returns a Component which
96+
wraps the provided component (higher order component).

0 commit comments

Comments
 (0)