Skip to content

Commit 9ca0d91

Browse files
authored
v2.0.3
* feat(config): support `Boolean` and `Function` types as preserve options for config and when emitting actions * fix(firestoreConnect): fix issue with unsetting listeners on unmount - prescottprue#384 and [51 on `redux-firestore`](prescottprue/redux-firestore#51) - @danleavitt0 * feat(docs): query docs updated and formatting simplified * feat(docs): `Function` capability added to docs about `preserve` config parameters
2 parents 6d1b7ac + a48604b commit 9ca0d91

12 files changed

+455
-262
lines changed

.codeclimate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ languages:
33

44
exclude_paths:
55
- "lib/**"
6-
- "tests/**"
6+
- "test/**"
77
- "examples/**"
88
- "LICENSE"
99
- "LICENSE.md"

docs/api/constants.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ Default configuration options
9595
with parts of state to preserve, and the values are Arrays contain keys
9696
for keys within that slice of state to preserve.
9797
- `preserveOnEmptyAuthChange` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** `null` Data parameters to
98-
preserve when logging out. Keys associate with parts of state to preserve,
99-
and the values are Arrays contain keys for keys within that slice of state
100-
to preserve.
98+
preserve when empty auth changes occur. Keys associate with parts of state
99+
to preserve, and the values are either Arrays or Functions. If passing an
100+
array of keys (i.e. `{ auth: ['key1', 'key2'] }`) - those keys (`'key1'` and
101+
`'key2'`) are preserved from that slice of state (`auth`). If passing a
102+
function (i.e. `{ auth: (currentAuthState, nextAuthState) => ({}) }`),
103+
whatever is returned from the function is set to that slice of state (`auth`).
101104
- `updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to update
102105
user profile when logging in.
103106
- `resetBeforeLogin` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to reset auth

docs/api/enhancer.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ along side applyMiddleware.
2929
and auth state on login
3030
- `config.perserveOnLogout` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** Data parameters to perserve
3131
when logging out. If Array is passed, each item represents keys
32-
within state.firebase.data preserve. If an object is passed, Keys associate
33-
with parts of state to preserve, and the values are Arrays which
32+
within `state.firebase.data` to preserve. If an object is passed,
33+
keys associate with slices of state to preserve, and the values can be either
34+
an `Array` or a `Function` (argument pattern: `(currentState, nextState)`).
35+
If passing an array of keys (i.e. `{ auth: ['key1', 'key2'] }`) - those keys
36+
(`'key1'` and `'key2'`) are preserved from that slice of state (`auth`). If
37+
passing a function (i.e.
38+
`{ auth: (currentAuthState, nextAuthState) => ({}) }`),
39+
whatever is returned from the function is set to that slice of state (`auth`).
3440
associate with which keys to preserve form that section of state.
3541
(default: `null`)
3642
- `config.preserveOnEmptyAuthChange` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** `null` Data parameters to

docs/auth.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Authentication Methods
22

3-
Authentication data is attached to `auth`, profile is attached to `profile` if you provide a value to the `userProfile` config option. You can get them within components like so:
3+
Authentication data is attached to `state.firebase.auth`, profile is attached to `state.firebase.profile` if you provide a value to the `userProfile` config option. You can get them within components like so:
44

55
```js
66
import { connect } from 'react-redux'
7-
connect(
8-
// Map state to props
7+
8+
const enhance = connect(
9+
// Map redux state to component props
910
({ firebase: { auth, profile } }) => ({
1011
auth,
1112
profile
1213
})
1314
)
15+
16+
enhance(SomeComponent)
1417
```
1518

1619
If you need access to methods that are not available at the top level, you can access Firebase's Full Auth API using `props.firebase.auth()` or `getFirebase().auth()`.
@@ -64,13 +67,13 @@ export default firebaseConnect()(SomeComponent) // or withFirebase(SomeComponent
6467
{
6568
provider: "facebook | google | twitter",
6669
type: "popup | redirect", // popup is default
67-
scopes: ['email'] // email is default
70+
scopes: Array // email is default
6871
}
6972
```
7073
* credential (runs `ref.signInWithCredential(credential)`) :
7174
```js
7275
{
73-
credential : [firebase.auth.AuthCredential](https://firebase.google.com/docs/reference/js/firebase.auth.AuthCredential.html) // created using specific provider
76+
credential: firebase.auth.AuthCredential // created using specific provider
7477
}
7578
```
7679
The credential parameter is a firebase.auth.AuthCredential specific to the provider (i.e. `firebase.auth.GoogleAuthProvider.credential(null, 'some accessToken')`). For more details [please view the Firebase API reference](https://firebase.google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#methods)
@@ -92,7 +95,7 @@ export default firebaseConnect()(SomeComponent) // or withFirebase(SomeComponent
9295
```js
9396
{
9497
phoneNumber: String,
95-
applicationVerifier: [`firebase.auth.ApplicationVerifier`](https://firebase.google.com/docs/reference/js/firebase.auth.ApplicationVerifier.html)
98+
applicationVerifier: firebase.auth.ApplicationVerifier
9699
}
97100
```
98101

0 commit comments

Comments
 (0)