Skip to content

Commit

Permalink
Reorder the params for binding
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
tgolen committed Aug 9, 2020
1 parent cbc7368 commit 9b8a3b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/WithStoreSubscribeToState.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function (mapStoreToStates) {
// Subscribe each of the state properties to the proper store key
_.each(mapStoreToStates, (mapStoreToState, propertyName) => {
const {key, path} = mapStoreToState;
this.bind(key, propertyName, path, null, this.wrappedComponent);
this.bind(key, path, null, propertyName, this.wrappedComponent);
});

// Call any loaders that will fill the store with their initial data
Expand All @@ -45,12 +45,12 @@ export default function (mapStoreToStates) {
* mapStoreToStates to this HOC. All subscriptions will automatically be unbound when unmounted
*
* @param {string} key
* @param {string} propertyName
* @param {string} path
* @param {string} propertyName
* @param {object} component
*/
bind(key, propertyName, path, defaultValue, component) {
this.subscriptionIDs.push(Store.bind(key, propertyName, path, defaultValue, component));
bind(key, path, defaultValue, propertyName, component) {
this.subscriptionIDs.push(Store.bind(key, path, defaultValue, propertyName, component));
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/page/HomePage/SidebarLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SidebarLink extends React.Component {
}

componentDidMount() {
this.props.bind(`${STOREKEYS.REPORT}_${this.props.reportID}`, 'isUnread', 'hasUnread', false, this);
this.props.bind(`${STOREKEYS.REPORT}_${this.props.reportID}`, 'hasUnread', false, 'isUnread', this);
}

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/store/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const callbackToStateMapping = {};
* Subscribes a react component's state directly to a store key
*
* @param {string} keyPattern
* @param {string} statePropertyName the name of the property in the state to bind the data to
* @param {string} path a specific path of the store object to map to the state
* @param {mixed} defaultValue to return if the there is nothing from the store
* @param {string} statePropertyName the name of the property in the state to bind the data to
* @param {object} reactComponent whose setState() method will be called with any changed data
* @returns {number} an ID to use when calling unbind
*/
function bind(keyPattern, statePropertyName, path, defaultValue, reactComponent) {
function bind(keyPattern, path, defaultValue, statePropertyName, reactComponent) {
const subscriptionID = lastSubscriptionID++;
callbackToStateMapping[subscriptionID] = {
regex: RegExp(keyPattern),
Expand Down

0 comments on commit 9b8a3b8

Please sign in to comment.