Dynamic Flux store service.
No need to write custom stores/actions/dispatchers/everything, data will flow through your app like an 80 year old duodenum.
function APIService ($http, anux) {
return {
getUsers: getUsers,
getNewsFeed: getNewsFeed
};
function getUsers () {
return $http.get('/api/users')
.then(anux.dispatch('user'))
.catch(anux.error('user'));
}
function getNewsFeed () {
return $http.get('/api/news')
.then(anux.dispatch('news'))
.catch(anux.error('news'));
}
}
function MainCtrl ($scope, apiService, anux) {
...
apiService.getUsers();
apiService.getNewsFeed();
anux($scope)
.listenTo('user', function (users) {
$scope.users = users;
})
.listenTo('news', function (news) {
$scope.news = news;
})
.logErrors();
...
}