Skip to content

Instantly share code, notes, and snippets.

@dgieselaar
Last active March 24, 2017 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgieselaar/b740897f42c50c5ccaea to your computer and use it in GitHub Desktop.
Save dgieselaar/b740897f42c50c5ccaea to your computer and use it in GitHub Desktop.
let ctrl = this,
listType = 'following',
listItems,
state;
let fetchData = ( ) => {
state = 'pending';
$http({
url: `/api/user/list/${listType}`
})
.success( ( response ) => {
listItems = response;
state = 'resolved';
})
.error( ( response ) => {
listItems = null;
state = 'rejected';
});
};
ctrl.getListItems = ( ) => listItems;
ctrl.isLoading = ( ) => state === 'pending';
ctrl.setListType = ( type ) => {
if(listType !== type) {
listType = type;
fetchData();
}
};
let ctrl = this;
listType = 'following',
listResource = resource(
( ) => `/api/user/list/${listType}`,
{ scope: $scope }
);
ctrl.getListItems = ( ) => listResource.data();
ctrl.isLoading = ( ) => listResource.state() === 'pending';
ctrl.setListType = ( type ) => {
listType = type;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment