Created
May 26, 2019 15:19
-
-
Save fernyettheplant/9c3bbdf8dc213703361def977ee5479b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Action, Module, Mutation, VuexModule } from 'vuex-module-decorators' | |
import { Inject } from 'inversify-props' | |
import KanyeQuote from '@/models/KanyeQuote' | |
import IKanyeWestService from '@/services/IKanyeWestService' | |
@Module | |
export default class KanyeWest extends VuexModule { | |
@Inject() | |
private kanyeWestService!: IKanyeWestService | |
public kanyeQuote: KanyeQuote | null = null | |
@Action | |
public async fetchKanyeQuote (): Promise<void> { | |
try { | |
const kanyeQuote = await this.kanyeWestService.getQuote() | |
this.context.commit('setKanyeQuote', kanyeQuote) | |
} catch (error) { | |
console.error(error) | |
} | |
} | |
@Mutation | |
public setKanyeQuote (newKanyeQuote: KanyeQuote): void { | |
this.kanyeQuote = newKanyeQuote | |
} | |
get quote (): string { | |
return this.kanyeQuote !== null ? this.kanyeQuote.quote : '' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment