Skip to content

Instantly share code, notes, and snippets.

@webmasterdevlin
Created November 16, 2019 23:59
Show Gist options
  • Save webmasterdevlin/b7f57a8546174255d46b1c5006c3e70d to your computer and use it in GitHub Desktop.
Save webmasterdevlin/b7f57a8546174255d46b1c5006c3e70d to your computer and use it in GitHub Desktop.
computed
import { action, computed, createContextStore, thunk } from 'easy-peasy'
import { deleteHero, getHeroById, getHeroes, postHero, putHero } from './hero-service'
const HeroStore = createContextStore({
/*states here*/
/*actions thunk side effects here*/
/*actions here*/
/*computed values i.e. derived state*/
totalHeroes: computed(state => Object.values(state.heroes).length)
});
export default HeroStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment