You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: docs/api/constants.md
+6-3
Original file line number
Diff line number
Diff line change
@@ -95,9 +95,12 @@ Default configuration options
95
95
with parts of state to preserve, and the values are Arrays contain keys
96
96
for keys within that slice of state to preserve.
97
97
-`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`).
101
104
-`updateProfileOnLogin`**[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**`true` Whether or not to update
102
105
user profile when logging in.
103
106
-`resetBeforeLogin`**[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**`true` Whether or not to reset auth
Copy file name to clipboardExpand all lines: docs/api/enhancer.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,14 @@ along side applyMiddleware.
29
29
and auth state on login
30
30
-`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
31
31
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
whatever is returned from the function is set to that slice of state (`auth`).
34
40
associate with which keys to preserve form that section of state.
35
41
(default: `null`)
36
42
-`config.preserveOnEmptyAuthChange`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**`null` Data parameters to
Copy file name to clipboardExpand all lines: docs/auth.md
+9-6
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,19 @@
1
1
# Authentication Methods
2
2
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:
4
4
5
5
```js
6
6
import { connect } from'react-redux'
7
-
connect(
8
-
// Map state to props
7
+
8
+
constenhance=connect(
9
+
// Map redux state to component props
9
10
({ firebase: { auth, profile } }) => ({
10
11
auth,
11
12
profile
12
13
})
13
14
)
15
+
16
+
enhance(SomeComponent)
14
17
```
15
18
16
19
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
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
74
77
}
75
78
```
76
79
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
0 commit comments