aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/store/galleryStore.ts
blob: 63e510977b9a82f574d0e10eb0ccb06a5486fd54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { createModule, mutation, action } from "vuex-class-component";

const VuexModule = createModule({
    namespaced: "galleryStore",
    strict: true
})

export default class GalleryStore extends VuexModule {

    galleryItems: Gallery.Item[] = [];

    @mutation setGalleryItems(galleryItems: Gallery.Item[]) {
        this.galleryItems = galleryItems;
    }

    @action async fetchGalleryItems(url: string) {
        fetch(url)
            .then(response => response.json())
            .then(this.setGalleryItems);
    }
}