Skip to content

Commit 91f4248

Browse files
authored
Version v2.0.0 Beta (#182)
### Features * [X] Keeping data on logout - #125 * [X] Listeners now kept on state (follows byId/allIds pattern [from redux docs](http://redux.js.org/docs/recipes/reducers/UpdatingNormalizedData.html)) * [X] `ordered` reducer added for managing ordered state (`SET_ORDERED` no longer used) * [X] `populate` works for profile (needed to remove share population logic) * [X] Presence capability added to show currently logged in users and track user sessions (`presence` in config) * [X] Firebase is no longer a dependency (build size, native compatibility, bundling for boilerplates, etc.) - #173, #131, #107 ### Fixes/Enhancements * Drop support for passing Firebase instance * Auto profile population removed (profile population will require using populate) * `isLoaded` and `isEmpty` logic simplified * Tests passing with new syntax (including reducers) * Drop support and deprecation warning for `profileDecorator` (use `profileFactory`) * Drop support and deprecation warning for `distpatchOnUnsetListener` (use `distpatchOnUnsetListener`, note incorrect spelling) * Tests no longer skipped from linting * Tons of other code simplifications
1 parent 5f7c768 commit 91f4248

Some content is hidden

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

49 files changed

+1620
-1424
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
examples/**
22
coverage/**
33
node_modules/**
4-
*.spec.js

.eslintrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ ecmaFeatures:
1515
jsx: true
1616
modules: true
1717

18-
globals:
19-
MockFirebase: true
20-
sinon: true
21-
Raven: true
22-
__COVERAGE__: true
23-
__DEV__: true
24-
2518
rules:
2619
semi: [2, 'never']
2720
no-console: 'error'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ npm install --save react-redux-firebase
4141

4242
## Use
4343

44-
Include reduxFirebase in your store compose function:
44+
Include reactReduxFirebase in your store compose function:
4545

4646

4747
```javascript

docs/api/compose.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,28 @@ _Setup_
5454
```javascript
5555
import { createStore, compose } from 'redux'
5656
import { reactReduxFirebase } from 'react-redux-firebase'
57+
import * as firebase from 'firebase'
5758

5859
// React Redux Firebase Config
5960
const config = {
6061
userProfile: 'users', // saves user profiles to '/users' on Firebase
6162
// here is where you place other config options
6263
}
6364

65+
// initialize script from Firebase page
66+
const fbConfg = {} // firebase config object
67+
firebase.initializeApp(fbConfig)
68+
6469
// Add react-redux-firebase to compose
6570
// Note: In full projects this will often be within createStore.js or store.js
6671
const createStoreWithFirebase = compose(
67-
reactReduxFirebase(fbConfig, config),
72+
reactReduxFirebase(firebase, config),
6873
)(createStore)
6974

7075
// Use Function later to create store
7176
const store = createStoreWithFirebase(rootReducer, initialState)
7277
```
7378

74-
_Custom Auth Parameters_
75-
76-
```javascript
77-
// Follow Setup example with the following config:
78-
const config = {
79-
customAuthParameters: {
80-
google: {
81-
// prompts user to select account on every google login
82-
prompt: 'select_account'
83-
}
84-
}
85-
}
86-
```
87-
8879
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
8980

9081
# getFirebase

docs/api/constants.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ Object containing all action types
1717

1818
- `START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/START`
1919
- `SET` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET`
20-
- `SET_ORDERED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_ORDERED`
2120
- `SET_PROFILE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_PROFILE`
2221
- `LOGIN` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN`
2322
- `LOGOUT` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGOUT`
2423
- `LOGIN_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/LOGIN_ERROR`
2524
- `NO_VALUE` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/NO_VALUE`
2625
- `UNAUTHORIZED_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNAUTHORIZED_ERROR`
26+
- `SET_LISTENER` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SET_LISTENER`
2727
- `UNSET_LISTENER` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/UNSET_LISTENER`
2828
- `AUTHENTICATION_INIT_STARTED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/AUTHENTICATION_INIT_STARTED`
2929
- `AUTHENTICATION_INIT_FINISHED` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/AUTHENTICATION_INIT_FINISHED`
30+
- `SESSION_START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SESSION_START`
31+
- `SESSION_END` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/SESSION_END`
3032
- `FILE_UPLOAD_START` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_START`
3133
- `FILE_UPLOAD_ERROR` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_ERROR`
3234
- `FILE_UPLOAD_PROGRESS` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `@@reactReduxFirebase/FILE_UPLOAD_PROGRESS`
@@ -59,6 +61,11 @@ Default configuration options
5961

6062
- `userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where user
6163
profiles are stored. Often set to `'users'`.
64+
- `presence` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where of currently
65+
online users is stored. Often set to `'presence'` or `'onlineUsers'`.
66+
- `sessions` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `sessions` Location on Firebase where user
67+
sessions are stored (only if presense is set). Often set to `'presence'` or
68+
`'onlineUsers'`.
6269
- `enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not firebase
6370
database logging is enabled.
6471
- `updateProfileOnLogin` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to update
@@ -71,7 +78,7 @@ Default configuration options
7178
empty auth changes such as `undefined` on initialization
7279
(see [#137](https://github.com/prescottprue/react-redux-firebase/issues/137)).
7380
Requires `v1.5.0-alpha` or higher.
74-
- `autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to
81+
- `autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` REMOVED FROM v2.0.0. Whether or not to
7582
automatically populate profile with data loaded through
7683
profileParamsToPopulate config.
7784
- `setProfilePopulateResults` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to

docs/api/helpers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Detect whether items are loaded yet or not
55
**Parameters**
66

77
- `item` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Item to check loaded status of. A comma seperated list is also acceptable.
8+
- `args` **...Any**
89

910
**Examples**
1011

@@ -24,7 +25,7 @@ Detect whether items are empty or not
2425
**Parameters**
2526

2627
- `item` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Item to check loaded status of. A comma seperated list is also acceptable.
27-
- `data`
28+
- `args` **...Any**
2829

2930
**Examples**
3031

docs/api/reducer.md

Lines changed: 94 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,73 @@
1-
# requestingReducer
1+
# isInitializingReducer
22

3-
Reducer for requesting state. Changed by `START` and `SET` actions.
3+
Reducer for isInitializing state. Changed by `AUTHENTICATION_INIT_STARTED`
4+
and `AUTHENTICATION_INIT_FINISHED` actions.
45

56
**Parameters**
67

7-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default {})** Current requesting redux state
8+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current isInitializing redux state (optional, default `false`)
89
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
10+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
911

1012
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
1113

12-
# dataReducer
14+
# requestingReducer
1315

14-
Reducer for data state. Changed by `LOGIN`, `LOGOUT`, and `LOGIN_ERROR`
15-
actions.
16+
Reducer for requesting state.Changed by `START`, `NO_VALUE`, and `SET` actions.
1617

1718
**Parameters**
1819

19-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default {})** Current data redux state
20-
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
20+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current requesting redux state (optional, default `{}`)
21+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
22+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
23+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
24+
- `$1` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
25+
- `$1.type`
26+
- `$1.path`
27+
28+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
29+
30+
# requestedReducer
31+
32+
Reducer for requested state. Changed by `START`, `NO_VALUE`, and `SET` actions.
33+
34+
**Parameters**
35+
36+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current requested redux state (optional, default `{}`)
37+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
38+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
39+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
40+
- `$1` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
41+
- `$1.type`
42+
- `$1.path`
43+
44+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
45+
46+
# timestampsReducer
47+
48+
Reducer for timestamps state. Changed by `START`, `NO_VALUE`, and `SET` actions.
49+
50+
**Parameters**
51+
52+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current timestamps redux state (optional, default `{}`)
53+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
54+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
55+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
56+
- `$1` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
57+
- `$1.type`
58+
- `$1.path`
2159

2260
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
2361

2462
# authReducer
2563

26-
Reducer for auth state. Changed by `LOGIN`, `LOGOUT`, and `LOGIN_ERROR`
27-
actions.
64+
Reducer for auth state. Changed by `LOGIN`, `LOGOUT`, and `LOGIN_ERROR` actions.
2865

2966
**Parameters**
3067

31-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default {})** Current auth redux state
32-
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
68+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current auth redux state (optional, default `{isLoaded:false}`)
69+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
70+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
3371

3472
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
3573

@@ -40,35 +78,66 @@ Reducer for profile state. Changed by `SET_PROFILE`, `LOGOUT`, and
4078

4179
**Parameters**
4280

43-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default null)** Current profile redux state
81+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current profile redux state (optional, default `{isLoaded:false}`)
4482
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
83+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
4584

4685
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
4786

48-
# isInitializingReducer
87+
# errorsReducer
4988

50-
Reducer for isInitializing state. Changed by `AUTHENTICATION_INIT_STARTED`
51-
and `AUTHENTICATION_INIT_FINISHED` actions.
89+
Reducer for errors state. Changed by `UNAUTHORIZED_ERROR`
90+
and `LOGOUT` actions.
5291

5392
**Parameters**
5493

55-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default false)** Current isInitializing redux state
56-
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
94+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current authError redux state (optional, default `[]`)
95+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
96+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
5797

5898
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
5999

60-
# errorsReducer
100+
# listenersReducer
61101

62-
Reducer for errors state. Changed by `UNAUTHORIZED_ERROR`
102+
Reducer for listeners state. Changed by `UNAUTHORIZED_ERROR`
63103
and `LOGOUT` actions.
64104

65105
**Parameters**
66106

67-
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)](default \[])** Current authError redux state
68-
- `action` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
107+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current authError redux state (optional, default `[]`)
108+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
109+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
69110

70111
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
71112

113+
# dataReducer
114+
115+
Reducer for data state. Changed by `SET`, `SET_ORDERED`,`NO_VALUE`, and
116+
`LOGOUT` actions.
117+
118+
**Parameters**
119+
120+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current data redux state (optional, default `{}`)
121+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
122+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
123+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
124+
125+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Data state after reduction
126+
127+
# orderedReducer
128+
129+
Reducer for ordered state. Changed by `SET`, `SET_ORDERED`,`NO_VALUE`, and
130+
`LOGOUT` actions.
131+
132+
**Parameters**
133+
134+
- `state` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Current data redux state (optional, default `{}`)
135+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
136+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
137+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
138+
139+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Data state after reduction
140+
72141
# firebaseStateReducer
73142

74143
Reducer for react redux firebase. This function is called
@@ -81,6 +150,7 @@ changes.
81150
- `state` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Current Redux State
82151
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Action which will modify state
83152
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of Action being called
84-
- `action.data` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of Action which will modify state
153+
- `action.path` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Path of action that was dispatched
154+
- `action.data` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Data associated with action
85155

86-
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** State
156+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Firebase redux state

0 commit comments

Comments
 (0)