import { Action, Module, Mutation, VuexModule } from 'vuex-module-decorators';

@Module({ namespaced: true })
export default class IndexModule extends VuexModule {
  count = 1;

  @Mutation
  increment(delta: number): void {
    this.count += delta;
  }
  @Mutation
  decrement(delta: number): void {
    this.count -= delta;
  }

  @Action({ commit: 'increment' })
  async incr(payload: number): Promise<number> {
    return new Promise((resolve) => {
      setTimeout(() => resolve(payload), 1000);
    });
  }
}
