vuex-mask

0.0.3 • Public • Published

vuex-mask

usage

@Module
export class Arsenal extends VuexMask {
    guns: Gun[] = [];
    budget = 5000;
    
    get countGuns() {
        return this.guns.length;
    }
    
    @Mutation
    addGun(gun: Gun) {
        this.guns.push(gun);
    }

	@Action
    async requestGunFromStore(gun: Gun) {
        if (gun.cost < this.budget) {
            //mutation for setter
            this.budget -= gun.cost;
            await this.gunDelivery();
            this.addGun(gun);
            return true;
        }
    
        return false;
    }

    gunDelivery() {
        return new Promise((resolve) => {
            setTimeout(resolve, 100);
        });
    }
}

// Store - Vuex instance
export default new Arsenal('arsenal', Store);

Readme

Keywords

none

Package Sidebar

Install

npm i vuex-mask

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

27.8 kB

Total Files

25

Last publish

Collaborators

  • wszerad