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

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

export default class GalleryStore extends VuexModule {

    galleryItems: Gallery.Item | null = null;

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

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

}