|
| 1 | +<!-- Generated by documentation.js. Update this documentation by updating the source code. --> |
| 2 | + |
| 3 | +### Table of Contents |
| 4 | + |
| 5 | +- [reactReduxFirebase](#reactreduxfirebase) |
| 6 | + |
| 7 | +## reactReduxFirebase |
| 8 | + |
| 9 | +Redux store enhancer that accepts configuration options and adds |
| 10 | +store.firebase and store.firebaseAuth. Enhancers are most commonly placed in redux's `compose` call |
| 11 | +along side applyMiddleware. |
| 12 | + |
| 13 | +**Parameters** |
| 14 | + |
| 15 | +- `instance` |
| 16 | +- `otherConfig` |
| 17 | + |
| 18 | +**Properties** |
| 19 | + |
| 20 | +- `firebaseInstance` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Initiated firebase instance (can also |
| 21 | + be library following Firebase JS API such as `react-native-firebase`) |
| 22 | +- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific configuration |
| 23 | + - `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user profiles |
| 24 | + - `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable Firebase database logging. |
| 25 | + **Note**: Only works if instance has enableLogging function. |
| 26 | + - `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved. |
| 27 | + - `config.presence` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Location on Firebase to store currently |
| 28 | + online users list. Often set to `'presence'` or `'onlineUsers'`. |
| 29 | + - `config.sessions` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Location on Firebase where user |
| 30 | + sessions are stored (only if presense is set). Often set to `'sessions'` or `'onlineUsers'`. |
| 31 | + - `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update |
| 32 | + profile when logging in. (default: `false`) |
| 33 | + - `config.resetBeforeLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to empty profile |
| 34 | + and auth state on login |
| 35 | + - `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable |
| 36 | + auth redirect handling listener. (default: `true`) |
| 37 | + - `config.onAuthStateChanged` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when auth state |
| 38 | + changes. Argument Pattern: `(authData, firebase, dispatch)` |
| 39 | + - `config.enableEmptyAuthChanges` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable |
| 40 | + empty auth changes. When set to true, `onAuthStateChanged` will be fired with, |
| 41 | + empty auth changes such as undefined on initialization. See |
| 42 | + [#137](https://github.com/prescottprue/react-redux-firebase/issues/137) for |
| 43 | + more details. (default: `false`) |
| 44 | + - `config.onRedirectResult` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when redirect |
| 45 | + result is returned. Argument Pattern: `(authData, firebase, dispatch)` |
| 46 | + - `config.customAuthParameters` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object for setting which |
| 47 | + customAuthParameters are passed to external auth providers. |
| 48 | + - `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved. |
| 49 | + - `config.fileMetadataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying |
| 50 | + how file meta data is written during file uploads |
| 51 | + - `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 |
| 52 | + profile object to populate. As of `v2.0.0` data is only loaded for population, not actually automatically populated |
| 53 | + (allows access to both unpopulated and populated profile data). |
| 54 | + - `config.autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** **NOTE**: Not yet enabled for v2.0.0. Whether or not to |
| 55 | + automatically populate profile with data loaded through profileParamsToPopulate config. (default: `true`) |
| 56 | + - `config.setProfilePopulateResults` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to |
| 57 | + call SET actions for data that results from populating profile to redux under |
| 58 | + the data path. For example role parameter on profile populated from 'roles' |
| 59 | + root. True will call SET_PROFILE as well as a SET action with the role that |
| 60 | + is loaded (places it in data/roles). (default: `false`) |
| 61 | + |
| 62 | +**Examples** |
| 63 | + |
| 64 | +_Setup_ |
| 65 | + |
| 66 | +```javascript |
| 67 | +import { createStore, compose } from 'redux' |
| 68 | +import { reactReduxFirebase } from 'react-redux-firebase' |
| 69 | +import * as firebase from 'firebase' |
| 70 | + |
| 71 | +// React Redux Firebase Config |
| 72 | +const config = { |
| 73 | + userProfile: 'users', // saves user profiles to '/users' on Firebase |
| 74 | + // here is where you place other config options |
| 75 | +} |
| 76 | + |
| 77 | +// initialize script from Firebase page |
| 78 | +const fbConfg = {} // firebase config object |
| 79 | +firebase.initializeApp(fbConfig) |
| 80 | + |
| 81 | +// Add react-redux-firebase to compose |
| 82 | +// Note: In full projects this will often be within createStore.js or store.js |
| 83 | +const createStoreWithFirebase = compose( |
| 84 | + reactReduxFirebase(firebase, config), |
| 85 | +)(createStore) |
| 86 | + |
| 87 | +// Use Function later to create store |
| 88 | +const store = createStoreWithFirebase(rootReducer, initialState) |
| 89 | +``` |
| 90 | + |
| 91 | +Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component and returns a Component which |
| 92 | +wraps the provided component (higher order component). |
0 commit comments