Skip to content

Commit b7d6064

Browse files
prescottprueScott Prue
authored and
Scott Prue
committed
Version v1.4.0 (#133)
* `react-native` support (including [complete example](https://github.com/prescottprue/react-redux-firebase/tree/v1.4.0-beta/examples/complete/react-native) app as well as a [create your own recipe](/docs/recipes/react-native.md)) * Server Side Rendering Support ([#72](#72)) * Support for Boilerplates ([#53](#53)) * `pushWithMeta`, `setWithMeta`, and `updateWithMeta` methods added - write to firebase with createdAt/updatedAt and createdBy/updatedBy * Fix for `unWatchEvent` helper dispatch mapping (#82) * `populatedDataToJS` triggers `isLoaded` to be true only when all data is populated (instead of once for unpopulated data) [#121](#121) * Support for `provider.setCustomParameters` on external auth providers (i.e. `provider.setCustomParameters({ prompt: 'select_account' })`) * `notParsed` query param option added for not parsing when using `equalTo` (for searching numbers stored as strings) * `profileParamsToPopulate` now works for `$key: true` lists (thanks @fej-snikduj) * `onRedirectResult` config option added (runs when redirect result occurs) * Improvements to Material Example * Projects route is now protected (using `UserIsAuthenticated` HOC from `utils/router`) * Todos list only displays first 8 (first at the top) - shows using ordering query params * Most main routes are now sync (more simple) * Firebase Library dependency updated to [`v3.9.0`](https://firebase.google.com/support/release-notes/js) * Fix for `unWatchEvent` helper dispatch mapping ([#82](#82)) * Firebase version is no longer fixed ([#109](#109)) * Only used parts of Firebase Library imported (shrinks bundle size) * `build:size` npm script added to generate size report for minified bundle ([#107](#107)) * `user` and `credential` are now returned from login method (solves [#106](#106)) * `yarn.lock` file added * Compose tests improved promise handling (better use of chai-as-promised) * `profileParamsToPopulate` now accepts `key: true` lists - thanks [@fej-snikduj](https://github.com/fej-snikduj)
1 parent f0d0386 commit b7d6064

File tree

154 files changed

+19454
-1172
lines changed

Some content is hidden

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

154 files changed

+19454
-1172
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
### Description
22

3-
Write here
3+
<!-- Write Your Description Here -->
4+
5+
### Questions
6+
<!-- Only include questions that apply to your pull request -->
7+
- Will a new version need to be released or is this a docs change?
8+
- Which version should this be published as a part of? ("ASAP", "no idea", and specific version number)
9+
10+
- Does this impact the external API?
11+
- Will it need to be a breaking change?
412

513
### Check List
614

7-
- [ ] All test passed
8-
- [ ] Added test to ensure to fix/ensure properly.
15+
- [ ] All tests passing
16+
- [ ] Docs updated with any changes or examples
17+
- [ ] Added tests to ensure feature(s) work properly
18+
19+
### Relevant Issues
20+
<!-- List Relevant Issues here like so:
21+
* [#1](https://github.com/prescottprue/react-redux-firebase/issues/#1)
22+
-->

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Dependency directory
22
node_modules
33
examples/**/node_modules
4-
dist
54
coverage
6-
_book
5+
dist
76
es
87
lib
8+
_book
99
# Logs
1010
*.log
11-
1211
.DS_Store
12+
examples/complete/react-native/ios/build

.npmignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ script:
1414
- npm run test:cov
1515

1616
cache:
17+
yarn: true
1718
directories:
1819
- node_modules
1920

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# react-redux-firebase
22

3-
[![Gitter][gitter-image]][gitter-url]
4-
53
[![NPM version][npm-image]][npm-url]
64
[![NPM downloads][npm-downloads-image]][npm-url]
75
[![Build Status][travis-image]][travis-url]
@@ -10,6 +8,9 @@
108
[![Code Coverage][coverage-image]][coverage-url]
119
[![Code Style][code-style-image]][code-style-url]
1210

11+
[![Gitter][gitter-image]][gitter-url]
12+
[<img src="http://npm.packagequality.com/badge/react-redux-firebase.png" align="right"/>](http://packagequality.com/#?package=react-redux-firebase)
13+
1314
> Redux bindings for Firebase. Includes Higher Order Component (HOC) for use with React.
1415
1516
## [Demo](https://demo.react-redux-firebase.com)
@@ -29,6 +30,8 @@ The [Material Example](https://github.com/prescottprue/react-redux-firebase/tree
2930
- [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/) integrations
3031
- Action Types and other Constants exported for external use (such as in `redux-observable`)
3132
- Firebase v3+ support
33+
- Server Side Rendering Support
34+
- [`react-native` support](/docs/recipes/react-native.md)
3235

3336
## Install
3437
```bash
@@ -183,6 +186,17 @@ export default compose(
183186

184187
```
185188

189+
## Server Side Rendering
190+
191+
Firebase's library requires XML request capability, so if you are using `react-redux-firebase` in a Server Side rendering environment, make sure you require `xmlhttprequest`.
192+
193+
If you disagree with having to do this yourself, hop [on gitter](https://gitter.im/redux-firebase/Lobby) and let us know!
194+
195+
```js
196+
// needed to fix "Error: The XMLHttpRequest compatibility library was not found."
197+
global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest
198+
```
199+
186200
## [Docs](http://react-redux-firebase.com)
187201
See full documentation at [react-redux-firebase.com](http://react-redux-firebase.com)
188202

@@ -254,9 +268,10 @@ import { pathToJS } from 'react-redux-firebase'
254268
export const addTodo = (newTodo) =>
255269
(dispatch, getState, getFirebase) => {
256270
const auth = pathToJS(getState.firebase, 'auth')
257-
newTodo.owner = auth.uid
271+
newTodo.createdBy = auth.uid //
258272
getFirebase()
259273
.push('todos', newTodo)
274+
// using pushWithMeta instead would attach createdBy and createdAt automatically
260275
.then(() => {
261276
dispatch({
262277
type: 'TODO_CREATED',
@@ -351,6 +366,7 @@ The [examples folder](/examples) contains full applications that can be copied/a
351366
* `uniqueSet` method helper for only setting if location doesn't already exist
352367
* Object or String notation for paths (`[{ path: '/todos' }]` equivalent to `['/todos']`)
353368
* Action Types and other Constants are exposed for external usage (such as with `redux-observable`)
369+
* Server Side Rendering Support
354370
* [Complete Firebase Auth Integration](http://react-redux-firebase.com/docs/auth.html#examples) including `signInWithRedirect` compatibility for OAuth Providers
355371

356372
#### Well why not combine?

SUMMARY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
* [Storage](/docs/storage.md)
99
* [Recipes](/docs/recipes/README.md)
1010
* [Profile](/docs/recipes/profile.md)
11-
* [Upload](/docs/recipes/upload.md)
11+
* [Auth](/docs/recipes/auth.md)
1212
* [Actions](/docs/recipes/actions.md)
1313
* [Thunks](/docs/recipes/thunks.md)
1414
* [Epics](/docs/recipes/epics.md)
1515
* [Routing](/docs/recipes/routing.md)
16-
* [Redux Form](/docs/recipes/redux-form.md)
1716
* [Populate](/docs/recipes/populate.md)
17+
* [Upload](/docs/recipes/upload.md)
18+
* [Redux Form](/docs/recipes/redux-form.md)
19+
* [React Native](/docs/recipes/react-native.md)
20+
* [Server Side Rendering](/docs/recipes/ssr.md)
1821
* [API Reference](/docs/api/README.md)
1922
* [constants](/docs/api/constants.md)
2023
* [firebaseConnect](/docs/api/connect.md)

docs/api/compose.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ Middleware that handles configuration (placed in redux's
2121
profile when logging in. (default: `false`)
2222
- `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable
2323
auth redirect handling listener. (default: `true`)
24+
- `config.onAuthStateChanged` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when auth state
25+
changes. Argument Pattern: `(authData, firebase, dispatch)`
26+
- `config.onRedirectResult` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when redirect
27+
result is returned. Argument Pattern: `(authData, firebase, dispatch)`
28+
- `config.customAuthParameters` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object for setting which
29+
customAuthParameters are passed to external auth providers.
2430
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved.
25-
- `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
31+
- `config.uploadFileDataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying
32+
how file meta data is written during file uploads
2633
- `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
2734
profile object to populate
2835
- `config.autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to
@@ -58,4 +65,18 @@ const createStoreWithFirebase = compose(
5865
const store = createStoreWithFirebase(rootReducer, initialState)
5966
```
6067

68+
_Custom Auth Parameters_
69+
70+
```javascript
71+
// Follow Setup example with the following config:
72+
const config = {
73+
customAuthParameters: {
74+
google: {
75+
// prompts user to select account on every google login
76+
prompt: 'select_account'
77+
}
78+
}
79+
}
80+
```
81+
6182
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

docs/auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default firebaseConnect()(SomeComponent)
7979

8080

8181
##### Returns
82-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with authData in case of success or the error otherwise.
82+
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with an object containing profile, user, (also credential if using oAuth provider) in case of success or the error otherwise.
8383

8484
##### Examples
8585

docs/queries.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Limit query results to the first n number of results.
9595
```javascript
9696
@firebaseConnect([
9797
'/todos#limitToFirst=10'
98-
// { path: '/todos', queryParams: [ 'orderByChild=owner', 'equalTo=123' ] } // object notation
98+
// { path: '/todos', queryParams: [ 'orderByChild=createdBy', 'equalTo=123' ] } // object notation
9999
])
100100
```
101101

@@ -128,7 +128,7 @@ Limit query results to include a range starting at a specific number
128128

129129
**Internal Method**: [ `limitToLast`](https://firebase.google.com/docs/reference/js/firebase.database.Query#limitToLast)
130130

131-
#### Example
131+
#### Examples
132132

133133
1. Starting at the fifth item
134134
```js
@@ -146,6 +146,9 @@ Limit query results to include a range starting at a specific number
146146
```
147147

148148
## endAt
149+
150+
#### Examples
151+
1. Usage with startAt
149152
```js
150153
@firebaseConnect([
151154
'todos#orderByChild=added&startAt=1&endAt=5'
@@ -156,15 +159,41 @@ Limit query results to include a range starting at a specific number
156159
## equalTo
157160
Limit query results with parameter equal to previous query method (i.e when used with orderByChild, it limits results with child equal to provided value). Internally runs [Firebase's `equalTo`](https://firebase.google.com/docs/reference/js/firebase.database.Query#equalTo).
158161

162+
### Parsing
163+
The following are internally parsed:
164+
* `null`
165+
* `boolean`
166+
* `number`
167+
168+
This means the actual value will be parsed instead of the string containing the value. If you do not want this to happen, look at the `notParsed` query parameter below.
169+
159170
#### Examples
160171
1. Order by child parameter
161172
```js
162173
@firebaseConnect([
163-
'todos#orderByChild=owner&equalTo=123',
164-
// { path: '/todos', queryParams: [ 'orderByChild=owner', 'equalTo=123' ] } // object notation
174+
'todos#orderByChild=createdBy&equalTo=ASD123',
175+
// { path: '/todos', queryParams: [ 'orderByChild=createdBy', 'equalTo=ASD123' ] } // object notation
165176
])
166177
```
167178

179+
## notParsed
180+
181+
Can be used to keep internal parsing from happening. Useful when attempting to search a number string using `equalTo`
182+
183+
#### Examples
184+
1. Order by child parameter equal to a number string. Equivalent of searching for `'123'` (where as not using `notParsed` would search for children equal to `123`)
185+
```js
186+
@firebaseConnect([
187+
{
188+
path: '/todos',
189+
queryParams: [
190+
'orderByChild=createdBy',
191+
'notParsed', // keeps equalTo from automatically parsing
192+
'equalTo=123'
193+
]
194+
}
195+
])
196+
```
168197

169198
## Populate {#populate}
170199

docs/recipes/actions.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
11
# Actions
22
react-redux-firebase comes with built in actions including `set`, `push`, and `update`
33

4+
## Components
5+
Firebase actions can be accessed within a component by using the `firebaseConnect` wrapper like so:
6+
7+
#### Pure Component
8+
```js
9+
import React, { PropTypes } from 'react'
10+
import { firebaseConnect } from 'react-redux-firebase'
11+
12+
const SimpleComponent = () => (
13+
<button onClick={() => this.props.firebase.push({ some: 'data' })}>
14+
Test Push
15+
</button>
16+
)
17+
18+
SimpleComponent.propTypes = {
19+
firebase: PropTypes.shape({
20+
push: PropTypes.func.isRequired
21+
})
22+
}
23+
24+
export default firebaseConnect()(SimpleComponent)
25+
```
26+
#### Stateful Component
27+
28+
```js
29+
import React, { Component, PropTypes } from 'react'
30+
import { firebaseConnect } from 'react-redux-firebase'
31+
32+
@firebaseConnect()
33+
export default class SimpleComponent extends Component {
34+
static propTypes = {
35+
firebase: PropTypes.shape({
36+
push: PropTypes.func.isRequired
37+
})
38+
}
39+
40+
state = {
41+
wasSent: false
42+
}
43+
44+
testPush = () => {
45+
this.props.firebase
46+
.push({ some: 'data' })
47+
.then(() => {
48+
this.setState({ wasSent: true })
49+
})
50+
}
51+
52+
render() {
53+
return (
54+
<button onClick={this.testPush}>
55+
Test Push
56+
</button>
57+
)
58+
}
59+
}
60+
```
61+
462
## Advanced Actions
563

664
If you are looking to write advanced actions (i.e. multiple steps contained within one action), look at the [thunks section](/docs/recipes/thunks)

0 commit comments

Comments
 (0)