mirror of
https://github.com/directus/directus.git
synced 2026-01-25 08:47:55 -05:00
Convert latency store to setup function (#18505)
This commit is contained in:
committed by
GitHub
parent
84bdf1e7b7
commit
2e5a4fd804
@@ -1,22 +1,26 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
type Latency = {
|
||||
latency: number;
|
||||
timestamp: Date;
|
||||
};
|
||||
|
||||
export const useLatencyStore = defineStore({
|
||||
id: 'latencyStore',
|
||||
state: () => ({
|
||||
latency: [] as Latency[],
|
||||
}),
|
||||
actions: {
|
||||
async dehydrate() {
|
||||
this.$reset();
|
||||
},
|
||||
save(latency: Latency) {
|
||||
this.latency.push(latency);
|
||||
this.latency = this.latency.slice(-20);
|
||||
},
|
||||
},
|
||||
export const useLatencyStore = defineStore('latencyStore', () => {
|
||||
const latency = ref<Latency[]>([]);
|
||||
|
||||
return {
|
||||
latency,
|
||||
dehydrate,
|
||||
save,
|
||||
};
|
||||
|
||||
async function dehydrate() {
|
||||
latency.value = [];
|
||||
}
|
||||
|
||||
function save(newLatency: Latency) {
|
||||
latency.value.push(newLatency);
|
||||
latency.value = latency.value.slice(-20);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user