Skip to content

Commit

Permalink
Rename subscribeToState to bind
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
tgolen committed Aug 9, 2020
1 parent 67ee483 commit e42283d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/WithStoreSubscribeToState.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function (mapStoreToStates) {
const {key, path} = mapStoreToState;
return [
...finalResult,
Store.subscribeToState(key, propertyName, path, null, this.wrappedComponent),
Store.bind(key, propertyName, path, null, this.wrappedComponent),
];
}, []);

Expand Down
6 changes: 3 additions & 3 deletions src/store/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const callbackToStateMapping = {};
* @param {object} reactComponent whose setState() method will be called with any changed data
* @returns {string} a guid to use when unsubscribing
*/
function subscribeToState(keyPattern, statePropertyName, path, defaultValue, reactComponent) {
function bind(keyPattern, statePropertyName, path, defaultValue, reactComponent) {
const subscriptionID = lastSubscriptionID++;
callbackToStateMapping[subscriptionID] = {
keyPattern,
Expand Down Expand Up @@ -107,7 +107,7 @@ function keyChanged(key, data) {
}
});

// Find components that were added with subscribeToState() and trigger their setState() method with the new data
// Find components that were added with bind() and trigger their setState() method with the new data
_.each(callbackToStateMapping, (mappedComponent) => {
const regex = RegExp(mappedComponent.keyPattern);

Expand Down Expand Up @@ -208,7 +208,7 @@ function merge(key, val) {
export {
subscribe,
unsubscribe,
subscribeToState,
bind,
unsubscribeFromState,
set,
multiSet,
Expand Down

0 comments on commit e42283d

Please sign in to comment.