Skip to content

Commit 7b8739a

Browse files
authored
v2.0.0-beta.8 (#263)
* fix(reducer): `MERGE` action added and `SET` action to reverted to v1 behavior - #255 * feat(populate): population of ordered data - #239 * feat(populate) populate once queries - #256 * feat(auth): emptyOnLogin config option added (defaults to `true`) - #254 * feat(query): emit `NO_VALUE` for `once` queries that are empty - #265 * fix(populate) Fixed populate function to return null for null paths * app instance handling now uses `firebase_` instead of `extendApp` (more functionality) - #250 * Removed no longer in use code from v1 (validateConfig)
1 parent 5558491 commit 7b8739a

31 files changed

+6883
-1547
lines changed

.babelrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
"comments": false
1616
},
1717
"test": {
18-
"plugins": ["transform-decorators-legacy"]
18+
"plugins": [
19+
"transform-runtime",
20+
"transform-decorators-legacy",
21+
"transform-async-to-generator"
22+
]
1923
}
2024
}
2125
}

_book

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/api/compose.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Middleware that handles configuration (placed in redux's
1111

1212
**Parameters**
1313

14-
- `fbApp`
14+
- `instance`
1515
- `otherConfig`
1616

1717
**Properties**
@@ -29,6 +29,8 @@ Middleware that handles configuration (placed in redux's
2929
sessions are stored (only if presense is set). Often set to `'sessions'` or `'onlineUsers'`.
3030
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update
3131
profile when logging in. (default: `false`)
32+
- `config.resetBeforeLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to empty profile
33+
and auth state on login
3234
- `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable
3335
auth redirect handling listener. (default: `true`)
3436
- `config.onAuthStateChanged` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when auth state

docs/api/constants.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ Object containing all action types
2727

2828
- `START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/START`
2929
- `SET` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET`
30+
- `MERGE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/MERGE`
3031
- `SET_PROFILE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_PROFILE`
3132
- `LOGIN` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN`
3233
- `LOGOUT` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGOUT`
3334
- `LOGIN_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN_ERROR`
3435
- `NO_VALUE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/NO_VALUE`
3536
- `UNAUTHORIZED_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNAUTHORIZED_ERROR`
37+
- `ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNAUTHORIZED_ERROR`
3638
- `SET_LISTENER` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_LISTENER`
3739
- `UNSET_LISTENER` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNSET_LISTENER`
3840
- `AUTHENTICATION_INIT_STARTED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/AUTHENTICATION_INIT_STARTED`

docs/contributing.md

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,76 @@
1111

1212
It is often convenient to run a local version of `react-redux-firebase` within a project to debug issues. The can be accomplished by doing the following:
1313

14-
1. Fork `react-redux-firebase` then cloning to your local machine (or download and unzip)
15-
1. Run `npm link` within your local `react-redux-firebase` folder
16-
1. Run `npm link react-redux-firebase` in your project (or one of the examples)
17-
1. Run `npm run watch` in your local `react-redux-firebase` folder to run a watch server that will rebuild as you make changes
18-
1. Your project should now be pointing to your local version of `react-redux-firebase`
14+
1. Fork `react-redux-firebase` then clone to your local machine
15+
1. Go into your local `react-redux-firebase` folder and run `npm link`
16+
1. Go into your project or one of the examples and run `npm link react-redux-firebase`
17+
1. Go Back in your `react-redux-firebase` folder
18+
1. Add/Change some code (placing a simple `console.log` is a nice way to confirm things are working)
19+
1. run `npm run build` to build a new version with your changes
20+
1. Your local version should now run when using `react-redux-firebase` within your project
1921

20-
**NOTE** The `commonjs` version is what is build when using `npm run watch`. If using a different version, use `npm run build` to build after you make changes.
22+
**NOTE**
23+
`npm run watch` can be used in your local `react-redux-firebase` folder to run a watch server that will rebuild as you make changes. Only the `commonjs` version is rebuild when using `npm run watch`. If using a different version, such as the `es` version, add watch flag to specific npm build command (i.e. `npm run build:es -- --watch`) to only rebuild that version when files are changed.
24+
25+
### Troubleshooting
26+
27+
* `Module build failed: ReferenceError: Unknown plugin`:
28+
29+
**Common Solution**
30+
31+
Include symlinked version of react-redux-firebase in your babel-loader excludes:
32+
33+
**Webpack 1**
34+
35+
```js
36+
{
37+
loaders: [
38+
{
39+
test: /\.(js|jsx)$/,
40+
exclude: [
41+
/node_modules/,
42+
/react-redux-firebase\/dist/, // browser version (most common in Webpack 1)
43+
/react-redux-firebase\/lib/, // commonjs version
44+
/react-redux-firebase\/es/ // es version
45+
],
46+
loader: 'babel',
47+
query: {
48+
cacheDirectory: true,
49+
plugins: ['transform-decorators-legacy'],
50+
presets: ['es2015', 'react']
51+
}
52+
}
53+
]
54+
55+
}
56+
```
57+
58+
**Webpack 2 & 3**
59+
60+
```js
61+
{
62+
rules: [
63+
{
64+
test: /\.(js|jsx)$/,
65+
exclude: [
66+
/node_modules/,
67+
/react-redux-firebase\/es/ // es version (since webpack 2/3 uses module field of package.json)
68+
],
69+
use: [
70+
{
71+
loader: 'babel-loader',
72+
query: {
73+
cacheDirectory: true,
74+
plugins: ['transform-decorators-legacy'],
75+
presets: ['es2015', 'react']
76+
}
77+
}
78+
]
79+
}
80+
]
81+
}
82+
```
83+
84+
**What Happened?**
85+
86+
This error most often appears due to Webpack config. A common pattern is to provide `exclude: [/node_modules/]` setting to [babel-loader](https://github.com/babel/babel-loader), which keeps the loader from transforming code within the `node_modules` folder. Now that we have used `npm link`, your project points to your local version of `react-redux-firebase` instead of the one in your `node_modules` folder, so we have to tell the loader to also exclude transforming `react-redux-firebase`.

docs/queries.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
# Queries
2+
Query listeners are attached by using the `firebaseConnect` higher order component. `firebaseConnect` accepts an array of paths for which to create queries. When listening to paths, it is possible to modify the query with any of [Firebase's included query methods](https://firebase.google.com/docs/reference/js/firebase.database.Query).
23

3-
When listening to paths, it is possible to modify the query with any of [Firebase's included query methods](https://firebase.google.com/docs/reference/js/firebase.database.Query). Below are examples using Firebase query methods as well as other methods that are included (such as 'populate').
4+
**NOTE:**
5+
By default the results of queries are stored in redux under the path of the query. If you would like to change where the query results are stored in redux, use [`storeAs` (more below)](#storeAs).
6+
7+
Below are examples using Firebase query methods as well as other methods that are included (such as 'populate').
8+
9+
`firebaseConnect` is a Higher Order Component (wraps a provided component) that attaches listeners to relevant paths on Firebase when mounting, and removes them when unmounting.
10+
11+
**storeAs**
12+
13+
Data is stored in redux under the path of the query for convince. This means that two different queries to the same path (i.e. `todos`) will both place data into `state.data.todos` even if their query parameters are different. If you would like to store your query somewhere else in redux, use `storeAs`:
14+
15+
```js
16+
@firebaseConnect([
17+
{
18+
path: 'todos',
19+
storeAs: 'myTodos', // place in redux under "myTodos"
20+
queryParams: ['orderByChild=createdBy', 'equalTo=123someuid'],
21+
}
22+
{
23+
path: 'todos',
24+
queryParams: ['limitToFirst=20'],
25+
}
26+
])
27+
@connect((state) => ({
28+
myTodos: state.firebase.data.myTodos, // due to storeAs
29+
allTodos: state.firebase.data.todos // state.firebase.data.todos since no storeAs
30+
}))
31+
```
432

533
## once
634
To load a firebase location once instead of binding, the once option can be used:

docs/recipes/routing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { firebaseConnect, isLoaded, isEmpty } from 'react-redux-firebase'
2121
@firebaseConnect()
2222
@connect(
2323
({ firebase: { auth } }) => ({
24-
auth,
24+
auth, // state.firebase.auth -> props.auth
2525
})
2626
)
2727
export default class ProtectedPage extends Component {
@@ -75,6 +75,7 @@ export const UserIsAuthenticated = UserAuthWrapper({
7575
},
7676
})
7777
```
78+
7879
**redux-auth-wrapper v2**
7980

8081
```js

examples/complete/material/build/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const config = {
5454
// ------------------------------------
5555
config.module.rules.push({
5656
test: /\.(js|jsx)$/,
57-
exclude: /node_modules/,
57+
exclude: [/node_modules/, /react-redux-firebase\/es/],
5858
use: [
5959
{
6060
loader: 'babel-loader',

examples/complete/material/project.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ module.exports = {
3434
'material-ui'
3535
],
3636
/**
37-
* Settings used to create config.js file when running npm run create-config
37+
* Settings used to create src/config.js using firebase-ci
3838
* in ci environment. If you are running locally, go to src/config.js.
39-
* NOTE: firebase-ci will soon be able to handle this for you :)
4039
*/
4140
ci: {
4241
development: {

examples/complete/material/src/routes/Home/containers/HomeContainer.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Theme from 'theme'
66
import {
77
firebaseConnect,
88
isLoaded,
9-
isEmpty
10-
// populate // for populated list
9+
isEmpty,
10+
populate // for populated list
1111
} from 'react-redux-firebase'
1212
import CircularProgress from 'material-ui/CircularProgress'
1313
import Snackbar from 'material-ui/Snackbar'
@@ -18,21 +18,23 @@ import TodoItem from '../components/TodoItem'
1818
import NewTodoPanel from '../components/NewTodoPanel'
1919
import classes from './HomeContainer.scss'
2020

21-
// const populates = [{ child: 'owner', root: 'users' }]
21+
const populates = [{ child: 'owner', root: 'users' }]
2222

2323
// Pass an array of path settings to create Firebase queries
2424
@firebaseConnect([
2525
// 'todos' // sync full list of todos
26-
// { path: 'todos', populates }, // gather data to populate owners (uid => object)
26+
{ path: 'todos', queryParams: ['orderByKey', 'limitToLast=10'], populates }, // gather data to populate owners (uid => object)
2727
// { path: 'todos', type: 'once' } // for loading once instead of binding
28-
{ path: 'todos', queryParams: ['orderByKey', 'limitToLast=10'] } // 10 most recent
28+
// { path: 'todos', queryParams: ['orderByKey', 'limitToLast=10'] } // 10 most recent
2929
// { path: 'todos', storeAs: 'myTodos' }, // store somewhere else in redux
3030
// { path: 'todos', queryParams: ['orderByKey', 'limitToLast=5'] } // 10 most recent
3131
])
32-
@connect(({ firebase: { auth, data: { todos } } }) => ({
32+
@connect(({ firebase, firebase: { auth, data: { todos } } }) => ({
3333
auth,
34-
todos
35-
// todos: populate(firebase, 'todos', populates) // populate todos with users data from redux
34+
// todos
35+
todos: populate(firebase, 'todos', populates), // populate todos with users data from redux
36+
// todos: populate(firebase, 'ordered/todos', populates) // populate todos with users data from redux
37+
// todos: populate(firebase, 'ordered/todos', populates) // populate todos with users data from redux
3638
// todos: firebase.ordered.todos // if using ordering such as orderByChild or orderByKey
3739
}))
3840
export default // Get data from redux and pass in as props

0 commit comments

Comments
 (0)