Skip to content

Commit 3e2de97

Browse files
authored
Version v1.2.0 (#37)
## Breaking Changes - Data gathered during population is now normalized in redux [following defined redux practice of normalizing](http://redux.js.org/docs/recipes/reducers/NormalizingStateShape.html) (instead of placed directly into nested object). **THIS BREAKS v1.1.5 AND EARLIER IMPLEMENTATIONS OF POPULATE**. Now population will require the usage of `populatedDataToJS`. - `populatedDataToJS` function added to helpers (returns data populated from normalized state) - `profileDecorator` config option renamed to `profileFactory` for clarity (`profileDecorator` still supported, but will throw deprecation warning) - default file metadata written to database includes `downloadURL` instead of `downloadURLs` array - Meta values (`timestamp`, `requesting`, `requested`) are now stored by string key (keeps invalid keyPath error from showing up) - `enableRedirectHandling` config param added to enable/disable auth redirect handling (enabled by default, which can cause breakage in none HTTP/HTTPS environments) ## Enhancements - `once` queries no longer cause `off` error due to unmounting non existent listener (fixes #36) - login with auth redirect no longer returns null and other redirect handling improvements (#33) - deep set `invalid keyPath` error fixed in data section of reducer (deep list is null first then has value) - `fileMetadataFactory` config option added to allow control of metadata written to database when using `uploadFile` and `uploadFiles` - Profile Params Populate now working for both object and string notation - Config params type validation - Roadmap updated with `v2.0.0` plans - `profileDecorator` backwards compatibility is included (with a deprecation warning) - `CODE_OF_CONDUCT.md` and `PATRONS.md` added - Docs + Tests updated
1 parent 0263b0b commit 3e2de97

Some content is hidden

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

50 files changed

+1754
-589
lines changed

CODE_OF_CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at prescottprue@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

PATRONS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Patrons
2+
3+
Meet some of the outstanding companies and individuals that made it possible:
4+
5+
* [Reside Network Inc.](https://github.com/reside-eng)

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ Install peer dependencies: `npm i --save redux react-redux`
4343

4444
### Decorators
4545

46-
Though they are optional, it is highly recommended that you used decorators with this library. [The Simple Example](examples/simple) shows implementation without decorators, while [the Decorators Example](examples/decorators) shows the same application with decorators implemented.
46+
Though they are optional, it is highly recommended that you use decorators with this library. [The Simple Example](examples/simple) shows implementation without decorators, while [the Decorators Example](examples/decorators) shows the same application with decorators implemented.
4747

4848
A side by side comparison using [react-redux](https://github.com/reactjs/react-redux)'s `connect` function/HOC is the best way to illustrate the difference:
4949

50+
#### Without Decorators
5051
```javascript
5152
class SomeComponent extends Component {
5253

@@ -55,6 +56,7 @@ export default connect()(SomeComponent)
5556
```
5657
vs.
5758

59+
#### With Decorators
5860
```javascript
5961
@connect()
6062
export default class SomeComponent extends Component {
@@ -112,7 +114,7 @@ const { isLoaded, isEmpty, dataToJS } = helpers
112114

113115
@firebaseConnect( [
114116
'/todos'
115-
// { type: 'once', path: '/todos' } // for loading once instead of binding
117+
// { path: '/todos' } // object notation
116118
])
117119
@connect(
118120
({ firebase }) => ({
@@ -178,8 +180,8 @@ export default connect(
178180

179181
```
180182

181-
## [Documentation](http://react-redux-firebase.com)
182-
See [react-redux-firebase.com](http://react-redux-firebase.com)
183+
## [Docs](http://react-redux-firebase.com)
184+
See full documentation at [react-redux-firebase.com](http://react-redux-firebase.com)
183185

184186
* [Getting Started](http://react-redux-firebase.com/docs/getting_started)
185187
* [Auth](http://react-redux-firebase.com/docs/auth)
@@ -189,7 +191,7 @@ See [react-redux-firebase.com](http://react-redux-firebase.com)
189191

190192
## [Examples](examples)
191193

192-
Examples folder is broken into two categories [complete](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete) and [snippets](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/snippets). Complete contains full applications that can be run as is, where as snippets is small amounts of code to show functionality (dev tools and deps not included).
194+
Examples folder is broken into two categories [complete](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete) and [snippets](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/snippets). `/complete` contains full applications that can be run as is, while `/snippets` contains small amounts of code to show functionality (dev tools and deps not included).
193195

194196
#### [State Based Query Snippet](examples/snippets/stateBasedQuery)
195197

@@ -276,9 +278,11 @@ const somethingEpic = (action$, store, getFirebase) =>
276278
)
277279
```
278280

279-
## Generator
281+
## Starting A Project
280282

281-
[generator-react-firebase](https://github.com/prescottprue/generator-react-firebase) uses react-redux-firebase when opting to include redux
283+
### Generator
284+
285+
[generator-react-firebase](https://github.com/prescottprue/generator-react-firebase) is a yeoman generator uses react-redux-firebase when opting to include redux
282286

283287
## FAQ
284288

@@ -293,19 +297,25 @@ const somethingEpic = (action$, store, getFirebase) =>
293297
* `uniqueSet` method helper for only setting if location doesn't already exist
294298
* Object or String notation for paths (`[{ path: '/todos' }]` equivalent to `['/todos']`)
295299
* Action Types and other Constants are exposed for external usage (such as with `redux-observable`)
300+
* [Complete Firebase Auth Integration](http://react-redux-firebase.com/docs/auth.html#examples) including `signInWithRedirect` compatibility for OAuth Providers
296301

297302
#### Well why not combine?
298303
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.
299304

300-
**Bottom line:** The author of redux-react-firebase was absent when functionality was needed by me and others, so this library was created.
301-
302305
2. Why use redux if I have Firebase to store state?
303306

304307
This isn't a super quick answer, so I wrote up [a medium article to explain](https://medium.com/@prescottprue/firebase-with-redux-82d04f8675b9)
305308

309+
310+
# Patrons
311+
312+
Meet some of the outstanding companies and individuals that made it possible:
313+
314+
* [Reside Network Inc.](https://github.com/reside-eng)
315+
316+
306317
## Contributors
307318
- [Prescott Prue](https://github.com/prescottprue)
308-
- [Tiberiu Craciun](https://github.com/tiberiuc)
309319
- [Bojhan](https://github.com/Bojhan)
310320
- [Rahav Lussto](https://github.com/RahavLussato)
311321
- [Justin Handley](https://github.com/justinhandley)

SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
* [Populate](/docs/populate.md)
88
* [Storage](/docs/storage.md)
99
* [Recipes](/docs/recipes/README.md)
10+
* [Profile](/docs/recipes/profile.md)
1011
* [Upload](/docs/recipes/upload.md)
1112
* [Actions](/docs/recipes/actions.md)
1213
* [Thunks](/docs/recipes/thunks.md)
14+
* [Epics](/docs/recipes/epics.md)
15+
* [Redux Form](/docs/recipes/redux-form.md)
1316
* [Populate](/docs/recipes/populate.md)
1417
* [API Reference](/docs/api/README.md)
1518
* [constants](/docs/api/constants.md)

docs/api/compose.md

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,42 @@
22

33
# reactReduxFirebase
44

5-
Middleware that handles configuration (placed in redux's `compose` call)
5+
Middleware that handles configuration (placed in redux's
6+
`compose` call)
67

7-
**Parameters**
8+
**Properties**
89

9-
- `fbConfig` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing Firebase config including databaseURL
10+
- `fbConfig` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing Firebase config including
11+
databaseURL
1012
- `fbConfig.apiKey` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase apiKey
1113
- `fbConfig.authDomain` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase auth domain
1214
- `fbConfig.databaseURL` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase database url
1315
- `fbConfig.storageBucket` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase storage bucket
1416
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific config such as userProfile
1517
- `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user profiles
16-
- `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Location on firebase to store user profiles. default: `false`
17-
- `config.profileDecorator` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Location on firebase to store user profiles. default: `false`
18-
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update profile when logging in. default: `false`
19-
- `config.profileParamsToPopulate` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Parameters within profile object to populate
18+
- `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable Firebase database logging
19+
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update profile when logging in. (default: `false`)
20+
- `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable auth redirect handling listener. (default: `true`)
21+
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved.
22+
- `config.uploadFileDataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how file meta data is written during file uploads
23+
- `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 profile object to populate
2024

2125
**Examples**
2226

23-
_Data_
27+
_Setup_
2428

2529
```javascript
2630
import { createStore, compose } from 'redux'
2731
import { reactReduxFirebase } from 'react-redux-firebase'
2832

29-
// Firebase config
30-
const fbConfig = {
31-
apiKey: '<your-api-key>',
32-
authDomain: '<your-auth-domain>',
33-
databaseURL: '<your-database-url>',
34-
storageBucket: '<your-storage-bucket>'
35-
}
36-
3733
// React Redux Firebase Config
3834
const config = {
39-
userProfile: 'users'
35+
userProfile: 'users', // saves user profiles to '/users' on Firebase
36+
// here is where you place other config options
4037
}
4138

4239
// Add react-redux-firebase to compose
40+
// Note: In full projects this will often be within createStore.js or store.js
4341
const createStoreWithFirebase = compose(
4442
reactReduxFirebase(fbConfig, config),
4543
)(createStore)
@@ -48,4 +46,46 @@ const createStoreWithFirebase = compose(
4846
const store = createStoreWithFirebase(rootReducer, initialState)
4947
```
5048

51-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Middleware function
49+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component a returns a wrapped version of component
50+
51+
# getFirebase
52+
53+
Expose Firebase instance created internally. Useful for
54+
integrations into external libraries such as redux-thunk and redux-observable.
55+
56+
**Examples**
57+
58+
_redux-thunk integration_
59+
60+
```javascript
61+
import { applyMiddleware, compose, createStore } from 'redux';
62+
import thunk from 'redux-thunk';
63+
import { reactReduxFirebase } from 'react-redux-firebase';
64+
import makeRootReducer from './reducers';
65+
import { getFirebase } from 'react-redux-firebase';
66+
67+
const fbConfig = {} // your firebase config
68+
69+
const store = createStore(
70+
makeRootReducer(),
71+
initialState,
72+
compose(
73+
applyMiddleware([
74+
// Pass getFirebase function as extra argument
75+
thunk.withExtraArgument(getFirebase)
76+
]),
77+
reactReduxFirebase(fbConfig)
78+
)
79+
);
80+
// then later
81+
export const addTodo = (newTodo) =>
82+
(dispatch, getState, getFirebase) => {
83+
const firebase = getFirebase()
84+
firebase
85+
.helpers
86+
.push('todos', newTodo)
87+
.then(() => {
88+
dispatch({ type: 'SOME_ACTION' })
89+
})
90+
};
91+
```

docs/api/connect.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ import { firebaseConnect } from 'react-redux-firebase'
2121
export default firebaseConnect()(App)
2222
```
2323

24-
_Paths_
25-
26-
```javascript
27-
import { connect } from 'react-redux'
28-
import { firebaseConnect, helpers } from 'react-redux-firebase'
29-
const { pathToJS } = helpers
30-
31-
// pass todos list from redux as this.props.todosList
32-
export default connect(({ firebase }) => ({
33-
profile: pathToJS(firebase, 'profile'),
34-
auth: pathToJS(firebase, 'auth')
35-
}))(App)
36-
```
37-
3824
_Data_
3925

4026
```javascript
@@ -49,7 +35,9 @@ const fbWrapped = firebaseConnect([
4935

5036
// pass todos list from redux as this.props.todosList
5137
export default connect(({ firebase }) => ({
52-
todosList: dataToJS(firebase, 'todos')
38+
todosList: dataToJS(firebase, 'todos'),
39+
profile: pathToJS(firebase, 'profile'), // pass profile data as this.props.proifle
40+
auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
5341
}))(fbWrapped)
5442
```
5543

docs/api/constants.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,41 @@ constants.actionsPrefix === '@@reactReduxFirebase' // true
1515

1616
Object containing all action types
1717

18+
**Properties**
19+
20+
- `START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/START`
21+
- `SET` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET`
22+
- `SET_PROFILE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_PROFILE`
23+
- `LOGIN` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN`
24+
- `LOGOUT` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGOUT`
25+
- `LOGIN_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN_ERROR`
26+
- `NO_VALUE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/NO_VALUE`
27+
- `UNAUTHORIZED_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNAUTHORIZED_ERROR`
28+
- `INIT_BY_PATH` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/INIT_BY_PATH`
29+
- `AUTHENTICATION_INIT_STARTED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/AUTHENTICATION_INIT_STARTED`
30+
- `AUTHENTICATION_INIT_FINISHED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/AUTHENTICATION_INIT_FINISHED`
31+
- `FILE_UPLOAD_START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_START`
32+
- `FILE_UPLOAD_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_ERROR`
33+
- `FILE_UPLOAD_PROGRESS` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_PROGRESS`
34+
- `FILE_UPLOAD_COMPLETE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_COMPLETE`
35+
- `FILE_DELETE_START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_DELETE_START`
36+
- `FILE_DELETE_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_DELETE_ERROR`
37+
- `FILE_DELETE_COMPLETE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_DELETE_COMPLETE`
38+
1839
**Examples**
1940

2041
```javascript
2142
import { actionTypes } from 'react-redux-firebase'
2243
actionTypes.SET === '@@reactReduxFirebase/SET' // true
2344
```
2445

25-
```javascript
26-
import { constants } from 'react-redux-firebase'
27-
constants.actionTypes.SET === '@@reactReduxFirebase/SET' // true
28-
```
46+
# defaultConfig
47+
48+
Default configuration options
49+
50+
**Properties**
51+
52+
- `userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where user profiles are stored. Often set to `'users'`.
53+
- `enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not firebase logging is enabled
54+
- `updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to update user profile when logging in
55+
- `enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to enable redirect handling

0 commit comments

Comments
 (0)