mirror of
https://github.com/directus/directus.git
synced 2026-02-17 01:31:48 -05:00
23 lines
501 B
TypeScript
23 lines
501 B
TypeScript
import { createStore } from 'pinia';
|
|
import { nanoid } from 'nanoid';
|
|
|
|
export const useRequestsStore = createStore({
|
|
id: 'requestsStore',
|
|
state: () => ({
|
|
queue: [] as string[],
|
|
}),
|
|
getters: {
|
|
queueHasItems: (state) => state.queue.length > 0,
|
|
},
|
|
actions: {
|
|
startRequest() {
|
|
const id = nanoid();
|
|
this.state.queue = [...this.state.queue, id];
|
|
return id;
|
|
},
|
|
endRequest(id: string) {
|
|
this.state.queue = this.state.queue.filter((queueID: string) => queueID !== id);
|
|
},
|
|
},
|
|
});
|