Skip to content

Instantly share code, notes, and snippets.

@dmachat
Created March 25, 2016 17:41
Show Gist options
  • Save dmachat/910caab5ade632894a84 to your computer and use it in GitHub Desktop.
Save dmachat/910caab5ade632894a84 to your computer and use it in GitHub Desktop.
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