Skip to content

Commit e9b4ca5

Browse files
authored
v1.0.0-alpha.2 (#149)
* fix(orderedReducer): fix issue where adding a document would break ordered structure - #151 * fix(ci): add alpha to travis branches config so tests run for alpha version - #151 * feat(query): support for populate using v1 state pattern (may have unexpected results, see note below) - #48 * fix(examples): complete example updated with `react-scripts` and `[email protected]` NOTE: The `populate` helper will need to work differently for v1.0.0 since things are stored differently in state. It will most likely not work when populating off of any `root` settings that are not at the base of the state tree.
1 parent 7e3269e commit e9b4ca5

File tree

150 files changed

+15699
-3704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+15699
-3704
lines changed

.babelrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
],
1111
"plugins": [
1212
"lodash",
13+
"transform-runtime",
1314
"transform-object-rest-spread",
14-
"transform-object-assign",
15+
"transform-object-assign"
1516
],
1617
"env": {
1718
"es": {
@@ -28,7 +29,6 @@
2829
},
2930
"test": {
3031
"plugins": [
31-
"transform-runtime",
3232
"transform-async-to-generator",
3333
["module-resolver", {
3434
"root": ["./src"]

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
examples/**
21
build/use-lodash-es.js
32
coverage/**
43
node_modules/**

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ rules:
2020
no-confusing-arrow: 0
2121
no-case-declarations: 0
2222
arrow-parens: [2, "as-needed"]
23+
prefer-default-export: 0

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ branches:
2222
only:
2323
- master
2424
- next
25+
- alpha
2526

2627
script:
2728
- npm run lint

README.md

+80-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const enhance = compose(
123123
props.store.firestore.add(todosQuery(), { ...newTodo, owner: 'Anonymous' }),
124124
}),
125125
lifecycle({
126-
componentWillMount(props) {
126+
componentDidMount(props) {
127127
props.loadData()
128128
}
129129
}),
@@ -151,7 +151,7 @@ class Todos extends Component {
151151
store: PropTypes.object.isRequired
152152
}
153153

154-
componentWillMount () {
154+
componentDidMount () {
155155
const { firestore } = this.context.store
156156
firestore.get('todos')
157157
}
@@ -457,16 +457,16 @@ Storing data under a different path within redux is as easy as passing the `stor
457457
Other Firebase statics (such as [FieldValue](https://firebase.google.com/docs/reference/js/firebase.firestore.FieldValue)) are available through the firestore instance:
458458

459459
```js
460+
import PropTypes from 'prop-types'
460461
import { connect } from 'react-redux'
461462
import {
462463
compose,
463464
withHandlers,
464-
lifecycle,
465465
withContext,
466466
getContext
467467
} from 'recompose'
468468

469-
const withFirestore = compose(
469+
const withStore = compose(
470470
withContext({ store: PropTypes.object }, () => {}),
471471
getContext({ store: PropTypes.object }),
472472
)
@@ -487,6 +487,82 @@ const enhance = compose(
487487
export default enhance(SomeComponent)
488488
```
489489

490+
### Population
491+
Population, made popular in [react-redux-firebase](http://react-redux-firebase.com/docs/recipes/populate.html), also works with firestore.
492+
493+
494+
#### Automatic Listeners
495+
```js
496+
import { connect } from 'react-redux'
497+
import { firestoreConnect, populate } from 'react-redux-firebase'
498+
import {
499+
compose,
500+
withHandlers,
501+
lifecycle,
502+
withContext,
503+
getContext
504+
} from 'recompose'
505+
506+
const populates = [{ child: 'createdBy', root: 'users' }]
507+
const collection = 'projects'
508+
509+
const withPopulatedProjects = compose(
510+
firestoreConnect((props) => [
511+
{
512+
collection,
513+
populates
514+
}
515+
]),
516+
connect((state, props) => ({
517+
projects: populate(state.firestore, collection, populates)
518+
}))
519+
)
520+
```
521+
522+
#### Manually using setListeners
523+
```js
524+
import { withFirestore, populate } from 'react-redux-firebase'
525+
import { connect } from 'react-redux'
526+
import { compose, lifecycle } from 'recompose'
527+
528+
const collection = 'projects'
529+
const populates = [{ child: 'createdBy', root: 'users' }]
530+
531+
const enhance = compose(
532+
withFirestore,
533+
lifecycle({
534+
componentDidMount() {
535+
this.props.firestore.setListener({ collection, populates })
536+
}
537+
}),
538+
connect(({ firestore }) => ({ // state.firestore
539+
todos: firestore.ordered.todos,
540+
}))
541+
)
542+
```
543+
544+
#### Manually using get
545+
```js
546+
import { withFirestore, populate } from 'react-redux-firebase'
547+
import { connect } from 'react-redux'
548+
import { compose, lifecycle } from 'recompose'
549+
550+
const collection = 'projects'
551+
const populates = [{ child: 'createdBy', root: 'users' }]
552+
553+
const enhance = compose(
554+
withFirestore,
555+
lifecycle({
556+
componentDidMount() {
557+
this.props.store.firestore.get({ collection, populates })
558+
}
559+
}),
560+
connect(({ firestore }) => ({ // state.firestore
561+
todos: firestore.ordered.todos,
562+
}))
563+
)
564+
```
565+
490566
## Config Options
491567
Optional configuration options for redux-firestore, provided to reduxFirestore enhancer as optional second argument. Combine any of them together in an object.
492568

examples/basic/jsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "./src"
4+
},
5+
"exclude": [
6+
"node_modules",
7+
"public",
8+
]
9+
}

examples/complete/.env.local

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NODE_PATH=src/
2+
CI=false
3+
# Needed to skip warnings from jest@beta in package.json
4+
SKIP_PREFLIGHT_CHECK=true

examples/complete/.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
coverage/**
1+
**/coverage/**
22
**/node_modules/**
33
dist/**
44
src/index.html

examples/complete/.eslintrc

-35
This file was deleted.

examples/complete/.eslintrc.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['react-app', 'prettier'],
4+
plugins: ['import', 'babel', 'react', 'prettier'],
5+
settings: {
6+
react: {
7+
version: '16.6'
8+
},
9+
'import/resolver': {
10+
node: {
11+
moduleDirectory: ['node_modules', '/']
12+
}
13+
}
14+
},
15+
rules: {
16+
semi: [
17+
2, 'never'
18+
],
19+
'no-console': 'error',
20+
'react/forbid-prop-types': 0,
21+
'react/require-default-props': 0,
22+
'react/jsx-filename-extension': 0,
23+
'import/no-named-as-default': 0,
24+
'prettier/prettier': [
25+
'error',
26+
{
27+
singleQuote: true,
28+
trailingComma: 'none',
29+
semi: false,
30+
bracketSpacing: true,
31+
jsxBracketSameLine: true,
32+
printWidth: 80,
33+
tabWidth: 2,
34+
useTabs: false
35+
}
36+
]
37+
},
38+
overrides: [
39+
{
40+
files: ['*.test.js', '*.spec.js'],
41+
env: {
42+
jest: true
43+
}
44+
},
45+
{
46+
files: ['config/*', 'scripts/*'],
47+
rules: {
48+
'no-console': 0,
49+
'func-names': 0,
50+
'prefer-destructuring': 0,
51+
'no-use-before-define': 0,
52+
'import/order': 0,
53+
'consistent-return': 0,
54+
'no-param-reassign': 0,
55+
'import/no-extraneous-dependencies': 0,
56+
'global-require': 0,
57+
'import/no-dynamic-require': 0
58+
}
59+
}
60+
]
61+
}

examples/complete/.firebaserc

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,30 @@
11
{
22
"projects": {
3-
"master": "redux-firebasev3",
4-
"prod": "redux-firebasev3"
3+
"default": "redux-firestore",
4+
"master": "redux-firestore",
5+
"prod": "redux-firestore"
56
},
67
"ci": {
8+
"copyVersion": true,
79
"createConfig": {
810
"master": {
9-
"version": "${npm_package_version}",
10-
"env": "development",
11+
"env": "staging",
1112
"firebase": {
12-
"apiKey": "AIzaSyCTUERDM-Pchn_UDTsfhVPiwM4TtNIxots",
13-
"authDomain": "redux-firebasev3.firebaseapp.com",
14-
"databaseURL": "https://redux-firebasev3.firebaseio.com",
15-
"projectId": "redux-firebasev3",
16-
"storageBucket": "redux-firebasev3.appspot.com"
17-
},
18-
"reduxFirebase": {
19-
"userProfile": "users",
20-
"enableLogging": false,
21-
"updateProfileOnLogin": false
13+
"apiKey": "${STAGE_FIREBASE_API_KEY}",
14+
"authDomain": "redux-firestore.firebaseapp.com",
15+
"databaseURL": "https://redux-firestore.firebaseio.com",
16+
"projectId": "redux-firestore",
17+
"storageBucket": "redux-firestore.appspot.com"
2218
}
2319
},
2420
"prod": {
25-
"version": "${npm_package_version}",
2621
"env": "production",
2722
"firebase": {
28-
"apiKey": "AIzaSyCTUERDM-Pchn_UDTsfhVPiwM4TtNIxots",
29-
"authDomain": "redux-firebasev3.firebaseapp.com",
30-
"databaseURL": "https://redux-firebasev3.firebaseio.com",
31-
"projectId": "redux-firebasev3",
32-
"storageBucket": "redux-firebasev3.appspot.com"
33-
},
34-
"reduxFirebase": {
35-
"userProfile": "users",
36-
"enableLogging": false,
37-
"updateProfileOnLogin": false
23+
"apiKey": "${PROD_FIREBASE_API_KEY}",
24+
"authDomain": "redux-firestore.firebaseapp.com",
25+
"databaseURL": "https://redux-firestore.firebaseio.com",
26+
"projectId": "redux-firestore",
27+
"storageBucket": "redux-firestore.appspot.com"
3828
}
3929
}
4030
}

examples/complete/.gitignore

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
# OS
12
*.log
23
**/*.log
34
.DS_Store
45
**/.DS_Store
5-
**/dist
6+
7+
# Dependencies
68
**/node_modules
7-
coverage
9+
10+
# React App
11+
**/dist
12+
src/config.js
13+
.env

0 commit comments

Comments
 (0)