Skip to content

Commit efbf8be

Browse files
authored
Docs + react-redux-firebase.com
* Docs are now part of repo (source downloaded from [gitbook.com version](https://www.gitbook.com/book/prescottprue/react-redux-firebase/details)) and published to [react-redux-firebase.com](http://react-redux-firebase.com) * docs npm scripts added: * `docs:clean` - cleans docs folders * `docs:prepare` - prepares for doc generation (installs gitbook-cli) * `docs:api` - generates API Reference section of docs from comments in code using [`documentation.js`](http://documentation.js.org/) * `docs:build` - builds docs into gitbook * `docs: watch` - builds docs into gitbook while watching for changes * `docs: publish` - publish docs to `gh-pages` branch (pointed to [react-redux-firebase.com](http://react-redux-firebase.com) using CNAME file)
2 parents fe9150e + db6a5ad commit efbf8be

32 files changed

+1537
-83
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ node_modules
33
examples/**/node_modules
44
dist
55
coverage
6+
_book
67

78
# Logs
89
*.log
910

1011
.DS_Store
11-
**/**/.DS_Store

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
react-redux-firebase.com

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Prescott Prue
3+
Copyright (c) 2016-present Prescott Prue
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+27-16
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515

1616
View deployed version of [Material Example](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete/material) [here](https://redux-firebasev3.firebaseapp.com/)
1717

18-
1918
## Features
2019
- Integrated into redux
2120
- Support for updating and nested props
22-
- [Population capability](https://prescottprue.gitbooks.io/react-redux-firebase/content/populate.html) (similar to mongoose's `populate` or SQL's `JOIN`)
21+
- [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
2322
- Out of the box support for authentication (with auto load user profile)
2423
- Firebase Storage Support
2524
- Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
@@ -120,7 +119,7 @@ const { isLoaded, isEmpty, dataToJS } = helpers
120119
todos: dataToJS(firebase, '/todos'),
121120
})
122121
)
123-
class Todos extends Component {
122+
export default class Todos extends Component {
124123
static propTypes = {
125124
todos: PropTypes.object,
126125
firebase: PropTypes.object
@@ -161,7 +160,6 @@ class Todos extends Component {
161160
)
162161
}
163162
}
164-
export default Todos
165163
```
166164

167165
Alternatively, if you choose not to use decorators:
@@ -179,8 +177,14 @@ export default connect(
179177

180178
```
181179

182-
## [API](https://prescottprue.gitbooks.io/react-redux-firebase/content/)
183-
See [API Docs](https://prescottprue.gitbooks.io/react-redux-firebase/content/)
180+
## [Documentation](http://react-redux-firebase.com)
181+
See [react-redux-firebase.com](http://react-redux-firebase.com)
182+
183+
* [Getting Started](http://react-redux-firebase.com/docs/getting_started)
184+
* [Auth](http://react-redux-firebase.com/docs/auth)
185+
* [Queries](http://react-redux-firebase.com/docs/queries)
186+
* [Populate](http://react-redux-firebase.com/docs/populate)
187+
* [API Reference](http://react-redux-firebase.com/docs/api)
184188

185189
## [Examples](examples)
186190

@@ -200,7 +204,11 @@ A simple example that was created using [create-react-app](https://github.com/fa
200204

201205
#### [Material App Example](examples/complete/material)
202206

203-
An example that user Material UI built on top of the output of [create-react-app](https://github.com/facebookincubator/create-react-app)'s eject command. Shows a list of todo items and allows you to add to them. This is what is deployed to [react-redux-firebase.firebaseapp.com](https://react-redux-firebase.firebaseapp.com/).
207+
An example that user Material UI built on top of the output of [create-react-app](https://github.com/facebookincubator/create-react-app)'s eject command. Shows a list of todo items and allows you to add to them. This is what is deployed to [redux-firebasev3.firebaseapp.com](https://redux-firebasev3.firebaseapp.com/).
208+
209+
## Discussion
210+
211+
Join the [redux-firebase gitter](https://gitter.im/redux-firebase/Lobby).
204212

205213
## Using with `redux-thunk`
206214
If you are using `redux-thunk`, make sure to set up your thunk middleware using it's redux-thunk's `withExtraArgument` method so that firebase is available within your actions. Here is an example `createStore` function that adds `getFirebase` as third argument along with a thunk that uses it:
@@ -214,15 +222,18 @@ import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
214222
import makeRootReducer from './reducers';
215223

216224
const fbConfig = {} // your firebase config
217-
225+
const config = {
226+
userProfile: 'users',
227+
enableLogging: false
228+
}
218229
const store = createStore(
219230
makeRootReducer(),
220231
initialState,
221232
compose(
222233
applyMiddleware([
223234
thunk.withExtraArgument(getFirebase) // Pass getFirebase function as extra argument
224235
]),
225-
reactReduxFirebase(fbConfig, { userProfile: 'users', enableLogging: false })
236+
reactReduxFirebase(fbConfig, )
226237
)
227238
);
228239

@@ -273,17 +284,17 @@ const somethingEpic = (action$, store, getFirebase) =>
273284
1. How is this different than [`redux-react-firebase`](https://github.com/tiberiuc/redux-react-firebase)?
274285

275286
This library was actually originally forked from redux-react-firebase, but adds extended functionality such as:
276-
* [populate functionality](https://prescottprue.gitbooks.io/react-redux-firebase/content/populate.html) (similar to mongoDB or SQL JOIN)
277-
* [`profileDecorator`](https://prescottprue.gitbooks.io/react-redux-firebase/content/config.html) - change format of profile stored on Firebase
278-
* [`getFirebase`](https://prescottprue.gitbooks.io/react-redux-firebase/content/thunks.html) - access to firebase instance that fires actions when methods are called
279-
* [integrations](https://prescottprue.gitbooks.io/react-redux-firebase/content/thunks.html) for [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org) - using `getFirebase`
280-
* [access to firebase's `storage`](https://prescottprue.gitbooks.io/react-redux-firebase/content/storage.html) method`
287+
* [populate functionality](http://react-redux-firebase.com/docs/populate) (similar to mongoDB or SQL JOIN)
288+
* [`profileDecorator`](http://react-redux-firebase.com/docs/config) - change format of profile stored on Firebase
289+
* [`getFirebase`](http://react-redux-firebase.com/docs/thunks) - access to firebase instance that fires actions when methods are called
290+
* [integrations](http://react-redux-firebase.com/docs/thunks) for [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org) - using `getFirebase`
291+
* [access to firebase's `storage`](http://react-redux-firebase.com/docs/storage) method`
281292
* `uniqueSet` method helper for only setting if location doesn't already exist
282293
* Object or String notation for paths (`[{ path: '/todos' }]` equivalent to `['/todos']`)
283-
* Action Types and other Constants are exposed for external usage (such as `redux-observable`)
294+
* Action Types and other Constants are exposed for external usage (such as with `redux-observable`)
284295

285296
#### Well why not combine?
286-
I have been talking to the author of [redux-react-firebase]() about combining, but we are not sure that the users of both want that at this point. Join us on [the redux-firebase gitter](https://gitter.im/redux-firebase/Lobby) if you haven't already since a ton of this type of discussion goes on there.
297+
I have been talking to the author of [redux-react-firebase](https://github.com/tiberiuc/redux-react-firebase) about combining, but we are not sure that the users of both want that at this point. Join us on the [redux-firebase gitter](https://gitter.im/redux-firebase/Lobby) if you haven't already since a ton of this type of discussion goes on there.
287298

288299
**Bottom line:** The author of redux-react-firebase was absent when functionality was needed by me and others, so this library was created.
289300

SUMMARY.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Summary
2+
3+
* [Read Me](/README.md)
4+
* [Getting Started](/docs/getting_started.md)
5+
* [Auth](/docs/auth.md)
6+
* [Queries](/docs/queries.md)
7+
* [Populate](/docs/populate.md)
8+
* [Storage](/docs/storage.md)
9+
* [Recipes](/docs/recipes/README.md)
10+
* [Upload](/docs/recipes/upload.md)
11+
* [Actions](/docs/recipes/actions.md)
12+
* [Thunks](/docs/recipes/thunks.md)
13+
* [API Reference](/docs/api/README.md)
14+
* [constants](/docs/api/constants.md)
15+
* [firebaseConnect](/docs/api/connect.md)
16+
* [firebaseStateReducer](/docs/api/reducer.md)
17+
* [reactReduxFirebase](/docs/api/compose.md)
18+
* [helpers](/docs/api/helpers.md)
19+
* [Roadmap](/docs/roadmap.md)
20+
* [Contributing](/docs/contributing.md)

bin/api-docs-generate.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const exec = require('child_process').exec
2+
const files = [
3+
{
4+
src: 'connect.js',
5+
dest: 'connect.md'
6+
},
7+
{
8+
src: 'compose.js',
9+
dest: 'compose.md'
10+
},
11+
{
12+
src: 'helpers.js',
13+
dest: 'helpers.md'
14+
},
15+
{
16+
src: 'reducer.js',
17+
dest: 'reducer.md'
18+
},
19+
{
20+
src: 'constants.js',
21+
dest: 'constants.md'
22+
}
23+
]
24+
const pathToDocumentationJs = 'node_modules/documentation/bin/documentation.js'
25+
26+
const generateDocForFile = (file) => {
27+
return new Promise((resolve, reject) => {
28+
exec(`${pathToDocumentationJs} build src/${file.src} -f md -o docs/api/${file.dest} --shallow`, (error, stdout) => {
29+
if (error !== null) {
30+
return reject(error)
31+
}
32+
resolve(stdout)
33+
})
34+
})
35+
}
36+
37+
(function () {
38+
files.forEach(file => {
39+
generateDocForFile(file)
40+
.then((res) => {
41+
console.log('Successfully generated', file) // eslint-disable-line no-console
42+
})
43+
.catch((err) => {
44+
console.log('error generating doc: ', err) // eslint-disable-line no-console
45+
})
46+
})
47+
})()

book.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"gitbook": ">=3.2.1",
3+
"title": "React Redux Firebase",
4+
"plugins": ["edit-link", "prism", "-highlight", "github", "anchorjs"],
5+
"pluginsConfig": {
6+
"edit-link": {
7+
"base": "https://github.com/prescottprue/react-redux-firebase/tree/master",
8+
"label": "Edit This Page"
9+
},
10+
"github": {
11+
"url": "https://github.com/prescottprue/react-redux-firebase/"
12+
},
13+
"theme-default": {
14+
"styles": {
15+
"website": "build/gitbook.css"
16+
}
17+
}
18+
}
19+
}

docs/GLOSSARY.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Glossary
2+
3+
## ## `profileDecorator`
4+

docs/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Summary
2+
3+
* [Read Me](/README.md)
4+
* [Getting Started](/docs/getting_started.md)
5+
* [Auth](/docs/auth.md)
6+
* [Queries](/docs/queries.md)
7+
* [Populate](/docs/populate.md)
8+
* [Storage](/docs/storage.md)
9+
* [Recipes](/docs/recipes/README.md)
10+
* [Upload](/docs/recipes/upload.md)
11+
* [Actions](/docs/recipes/actions.md)
12+
* [Thunks](/docs/recipes/thunks.md)
13+
* [API Reference](/docs/api/README.md)
14+
* [constants](/docs/api/constants.md)
15+
* [firebaseConnect](/docs/api/connect.md)
16+
* [firebaseStateReducer](/docs/api/reducer.md)
17+
* [reactReduxFirebase](/docs/api/compose.md)
18+
* [helpers](/docs/api/helpers.md)
19+
* [Roadmap](/docs/roadmap.md)
20+
* [Contributing](/docs/contributing.md)

docs/api/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# API Reference
2+
3+
Just like [redux](http://redux.js.org/docs/api/index.html), the react-redux-firebase API surface is small.
4+
5+
## Top-Level Exports
6+
* [firebaseConnect](/docs/api/connect.md)
7+
* [firebaseStateReducer](/docs/api/reducer.md)
8+
* [reactReduxFirebase](/docs/api/compose.md)
9+
* [constants](/docs/api/constants.md)
10+
* [actionTypes](/docs/api/constants.md)
11+
* [helpers](/docs/api/helpers.md)
12+
13+
## Importing
14+
15+
Every function described above is a top-level export. You can import any of them like this:
16+
17+
### ES6
18+
```js
19+
import { firebaseConnect } from 'react-redux-firebase'
20+
```
21+
22+
### ES5 (CommonJS)
23+
```js
24+
var firebaseConnect = require('react-redux-firebase').firebaseConnect
25+
```

docs/api/compose.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+
# reactReduxFirebase
4+
5+
Middleware that handles configuration (placed in redux's `compose` call)
6+
7+
**Parameters**
8+
9+
- `fbConfig` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing Firebase config including databaseURL
10+
- `fbConfig.apiKey` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase apiKey
11+
- `fbConfig.authDomain` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase auth domain
12+
- `fbConfig.databaseURL` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase database url
13+
- `fbConfig.storageBucket` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Firebase storage bucket
14+
- `config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Containing react-redux-firebase specific config such as userProfile
15+
- `config.userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Location on firebase to store user profiles
16+
- `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`
17+
- `config.profileDecorator` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Location on firebase to store user profiles. default: `false`
18+
- `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`
19+
- `config.profileParamsToPopulate` **[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+
21+
**Examples**
22+
23+
_Data_
24+
25+
```javascript
26+
import { createStore, compose } from 'redux'
27+
import { reactReduxFirebase } from 'react-redux-firebase'
28+
29+
// Firebase config
30+
const fbConfig = {
31+
apiKey: '<your-api-key>',
32+
authDomain: '<your-auth-domain>',
33+
databaseURL: '<your-database-url>',
34+
storageBucket: '<your-storage-bucket>'
35+
}
36+
37+
// React Redux Firebase Config
38+
const config = {
39+
userProfile: 'users'
40+
}
41+
42+
// Add react-redux-firebase to compose
43+
const createStoreWithFirebase = compose(
44+
reactReduxFirebase(fbConfig, config),
45+
)(createStore)
46+
47+
// Use Function later to create store
48+
const store = createStoreWithFirebase(rootReducer, initialState)
49+
```
50+
51+
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

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+
# firebaseConnect
4+
5+
**Extends React.Component**
6+
7+
Higher Order Component that automatically listens/unListens
8+
to provided firebase paths using React's Lifecycle hooks.
9+
10+
**Parameters**
11+
12+
- `watchArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of objects or strings for paths to sync from Firebase
13+
14+
**Examples**
15+
16+
_Basic_
17+
18+
```javascript
19+
// this.props.firebase set on App component as firebase object with helpers
20+
import { firebaseConnect } from 'react-redux-firebase'
21+
export default firebaseConnect()(App)
22+
```
23+
24+
_Paths_
25+
26+
```javascript
27+
import { connect } from 'react-redux'
28+
import { firebaseConnect, helpers } from 'react-redux-firebase'
29+
const { pathToJS } = helpers
30+
31+
// pass todos list from redux as this.props.todosList
32+
export default connect(({ firebase }) => ({
33+
profile: pathToJS(firebase, 'profile'),
34+
auth: pathToJS(firebase, 'auth')
35+
}))(App)
36+
```
37+
38+
_Data_
39+
40+
```javascript
41+
import { connect } from 'react-redux'
42+
import { firebaseConnect, helpers } from 'react-redux-firebase'
43+
const { dataToJS } = helpers
44+
45+
// sync /todos from firebase into redux
46+
const fbWrapped = firebaseConnect([
47+
'todos'
48+
])(App)
49+
50+
// pass todos list from redux as this.props.todosList
51+
export default connect(({ firebase }) => ({
52+
todosList: dataToJS(firebase, 'todos')
53+
}))(fbWrapped)
54+
```
55+
56+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** that accepts a component to wrap and returns the wrapped component

0 commit comments

Comments
 (0)