Created
March 25, 2016 17:41
-
-
Save dmachat/910caab5ade632894a84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import addData from 'addData'; | |
export default function inputController($scope, $ngRedux) { | |
// 'connect' returns an unsubscribe function, that we use when the directive is destroyed. | |
// values from the Redux store are bound to 'this' (or, the directive's scope), | |
// and updates on store updates | |
const disconnect = $ngRedux.connect((state) => { | |
return { | |
state: state.data, | |
}; | |
})(this); | |
// trigger unsubscribe | |
$scope.$on('$destroy', disconnect); | |
// trigger an update | |
this.onClickUpdate = () => { | |
$ngRedux.dispatch(update(addData({}))); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment