Skip to content

Commit

Permalink
Docs updated and published.
Browse files Browse the repository at this point in the history
  • Loading branch information
prescottprue committed Jan 16, 2017
1 parent 3064dc3 commit 0ce544a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
11 changes: 6 additions & 5 deletions docs/api/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ Middleware that handles configuration (placed in redux's
- `fbConfig.storageBucket` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase storage bucket
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific config such as userProfile
- `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user profiles
- `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`
- `config.profileDecorator` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Location on firebase to store user profiles. default: `false`
- `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`
- `config.profileParamsToPopulate` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Parameters within profile object to populate
- `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`)
- `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`)
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved
- `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
- `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

**Examples**

Expand All @@ -44,4 +45,4 @@ const createStoreWithFirebase = compose(
const store = createStoreWithFirebase(rootReducer, initialState)
```

Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Middleware function
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
5 changes: 2 additions & 3 deletions docs/api/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ import { connect } from 'react-redux'
import { firebaseConnect, helpers } from 'react-redux-firebase'
const { pathToJS } = helpers

// pass todos list from redux as this.props.todosList
export default connect(({ firebase }) => ({
profile: pathToJS(firebase, 'profile'),
auth: pathToJS(firebase, 'auth')
profile: pathToJS(firebase, 'profile'), // pass profile data as this.props.proifle
auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
}))(App)
```

Expand Down
33 changes: 33 additions & 0 deletions docs/api/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,39 @@ export default connect(({ firebase }) => ({

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

# populatedDataToJS

Convert parameter under "data" path of Immutable Map to a
Javascript object with parameters populated based on populates array

**Parameters**

- `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)
- `path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of parameter to load
- `populates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of populate objects
- `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
- `data`

**Examples**

_Basic_

```javascript
import { connect } from 'react-redux'
import { firebaseConnect, helpers } from 'react-redux-firebase'
const { dataToJS } = helpers

const fbWrapped = firebaseConnect(['/todos'])(App)

export default connect(({ firebase }) => ({
// this.props.todos loaded from state.firebase.data.todos
// each todo has child 'owner' populated from matching uid in 'users' root
todos: populatedDataToJS(firebase, 'todos', [{ child: 'owner', root: 'users' }])
}))(fbWrapped)
```

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

# customToJS

Load custom object from within store
Expand Down
5 changes: 2 additions & 3 deletions src/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import { getEventsFromInput, createCallable } from './utils'
* import { firebaseConnect, helpers } from 'react-redux-firebase'
* const { pathToJS } = helpers
*
* // pass todos list from redux as this.props.todosList
* export default connect(({ firebase }) => ({
* profile: pathToJS(firebase, 'profile'),
* auth: pathToJS(firebase, 'auth')
* profile: pathToJS(firebase, 'profile'), // pass profile data as this.props.proifle
* auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
* }))(App)
* @example <caption>Data</caption>
* import { connect } from 'react-redux'
Expand Down
14 changes: 14 additions & 0 deletions src/utils/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'lodash'

/**
* @private
* @description Create standardized populate object from strings or objects
* @param {String|Object} str - String or Object to standardize into populate object
*/
Expand All @@ -23,6 +24,7 @@ export const getPopulateObj = (str) => {
return { child: strArray[0], root: strArray[1] }
}
/**
* @private
* @description Create standardized populate object from strings or objects
* @param {String|Object} str - String or Object to standardize into populate object
*/
Expand All @@ -34,6 +36,7 @@ export const getPopulateObjs = (arr) => {
}

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

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

/**
* @private
* @description Populate list of data
* @param {Object} firebase - Internal firebase object
* @param {Object} originalObj - Object to have parameter populated
* @param {Object} populate - Object containing populate information
* @param {Object} results - Object containing results of population from other populates
*/
export const populateList = (firebase, originalData, p, results) => {
const mainChild = p.child.split('[]')[0]
const childParam = p.child.split('[]')[1]
Expand Down Expand Up @@ -99,7 +111,9 @@ export const populateList = (firebase, originalData, p, results) => {
})
)
}

/**
* @private
* @description Create an array of promises for population of an object or list
* @param {Object} firebase - Internal firebase object
* @param {Object} originalObj - Object to have parameter populated
Expand Down

0 comments on commit 0ce544a

Please sign in to comment.