Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
792 B

import { writable, get } from "svelte/store"
const initialState = {
showConfirmation: false,
title: null,
text: null,
callback: null,
}
const createConfirmationStore = () => {
const store = writable(initialState)
const showConfirmation = (title, text, callback) => {
store.set({
showConfirmation: true,
title,
text,
callback,
})
}
const confirm = async () => {
const state = get(store)
if (!state.showConfirmation || !state.callback) {
return
}
store.set(initialState)
await state.callback()
}
const cancel = () => {
store.set(initialState)
}
return {
subscribe: store.subscribe,
actions: { showConfirmation, confirm, cancel },
}
}
export const confirmationStore = createConfirmationStore()