Skip to content

Commit 0ce544a

Browse files
committed
Docs updated and published.
1 parent 3064dc3 commit 0ce544a

File tree

5 files changed

+57
-11
lines changed

5 files changed

+57
-11
lines changed

docs/api/compose.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ Middleware that handles configuration (placed in redux's
1515
- `fbConfig.storageBucket` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase storage bucket
1616
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific config such as userProfile
1717
- `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user profiles
18-
- `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Location on firebase to store user profiles. default: `false`
19-
- `config.profileDecorator` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Location on firebase to store user profiles. default: `false`
20-
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update profile when logging in. default: `false`
21-
- `config.profileParamsToPopulate` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Parameters within profile object to populate
18+
- `config.enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Location on firebase to store user profiles. (default: `false`)
19+
- `config.updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to update profile when logging in. (default: `false`)
20+
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved
21+
- `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
22+
- `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 profile object to populate
2223

2324
**Examples**
2425

@@ -44,4 +45,4 @@ const createStoreWithFirebase = compose(
4445
const store = createStoreWithFirebase(rootReducer, initialState)
4546
```
4647

47-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Middleware function
48+
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/api/connect.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ import { connect } from 'react-redux'
2828
import { firebaseConnect, helpers } from 'react-redux-firebase'
2929
const { pathToJS } = helpers
3030

31-
// pass todos list from redux as this.props.todosList
3231
export default connect(({ firebase }) => ({
33-
profile: pathToJS(firebase, 'profile'),
34-
auth: pathToJS(firebase, 'auth')
32+
profile: pathToJS(firebase, 'profile'), // pass profile data as this.props.proifle
33+
auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
3534
}))(App)
3635
```
3736

docs/api/helpers.md

+33
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,39 @@ export default connect(({ firebase }) => ({
109109

110110
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Data located at path within Immutable Map
111111

112+
# populatedDataToJS
113+
114+
Convert parameter under "data" path of Immutable Map to a
115+
Javascript object with parameters populated based on populates array
116+
117+
**Parameters**
118+
119+
- `firebase` **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)** Immutable Map to be converted to JS object (state.firebase)
120+
- `path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of parameter to load
121+
- `populates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of populate objects
122+
- `notSetValue` **([Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** Value to return if value is not found
123+
- `data`
124+
125+
**Examples**
126+
127+
_Basic_
128+
129+
```javascript
130+
import { connect } from 'react-redux'
131+
import { firebaseConnect, helpers } from 'react-redux-firebase'
132+
const { dataToJS } = helpers
133+
134+
const fbWrapped = firebaseConnect(['/todos'])(App)
135+
136+
export default connect(({ firebase }) => ({
137+
// this.props.todos loaded from state.firebase.data.todos
138+
// each todo has child 'owner' populated from matching uid in 'users' root
139+
todos: populatedDataToJS(firebase, 'todos', [{ child: 'owner', root: 'users' }])
140+
}))(fbWrapped)
141+
```
142+
143+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Data located at path within Immutable Map
144+
112145
# customToJS
113146

114147
Load custom object from within store

src/connect.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ import { getEventsFromInput, createCallable } from './utils'
1919
* import { firebaseConnect, helpers } from 'react-redux-firebase'
2020
* const { pathToJS } = helpers
2121
*
22-
* // pass todos list from redux as this.props.todosList
2322
* export default connect(({ firebase }) => ({
24-
* profile: pathToJS(firebase, 'profile'),
25-
* auth: pathToJS(firebase, 'auth')
23+
* profile: pathToJS(firebase, 'profile'), // pass profile data as this.props.proifle
24+
* auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
2625
* }))(App)
2726
* @example <caption>Data</caption>
2827
* import { connect } from 'react-redux'

src/utils/populate.js

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from 'lodash'
1212

1313
/**
14+
* @private
1415
* @description Create standardized populate object from strings or objects
1516
* @param {String|Object} str - String or Object to standardize into populate object
1617
*/
@@ -23,6 +24,7 @@ export const getPopulateObj = (str) => {
2324
return { child: strArray[0], root: strArray[1] }
2425
}
2526
/**
27+
* @private
2628
* @description Create standardized populate object from strings or objects
2729
* @param {String|Object} str - String or Object to standardize into populate object
2830
*/
@@ -34,6 +36,7 @@ export const getPopulateObjs = (arr) => {
3436
}
3537

3638
/**
39+
* @private
3740
* @description Get array of populates from list of query params
3841
* @param {Array} queryParams - Query parameters from which to get populates
3942
*/
@@ -49,6 +52,7 @@ export const getPopulates = (params) => {
4952
}
5053

5154
/**
55+
* @private
5256
* @description Create an array of promises for population of an object or list
5357
* @param {Object} firebase - Internal firebase object
5458
* @param {Object} populate - Object containing root to be populate
@@ -65,6 +69,14 @@ export const getPopulateChild = (firebase, populate, id) =>
6569
snap.val()
6670
)
6771

72+
/**
73+
* @private
74+
* @description Populate list of data
75+
* @param {Object} firebase - Internal firebase object
76+
* @param {Object} originalObj - Object to have parameter populated
77+
* @param {Object} populate - Object containing populate information
78+
* @param {Object} results - Object containing results of population from other populates
79+
*/
6880
export const populateList = (firebase, originalData, p, results) => {
6981
const mainChild = p.child.split('[]')[0]
7082
const childParam = p.child.split('[]')[1]
@@ -99,7 +111,9 @@ export const populateList = (firebase, originalData, p, results) => {
99111
})
100112
)
101113
}
114+
102115
/**
116+
* @private
103117
* @description Create an array of promises for population of an object or list
104118
* @param {Object} firebase - Internal firebase object
105119
* @param {Object} originalObj - Object to have parameter populated

0 commit comments

Comments
 (0)