Types notification

This commit is contained in:
Adria Navarro 2024-12-30 13:27:58 +01:00
parent 4ffb365c64
commit 4d784b530a
2 changed files with 13 additions and 4 deletions

View File

@ -98,7 +98,6 @@ export type Store = BaseStore &
sort: Writable<any> sort: Writable<any>
subscribe: any subscribe: any
dispatch: (event: string, data: any) => any dispatch: (event: string, data: any) => any
notifications: Writable<any>
width: Writable<number> width: Writable<number>
bounds: Readable<any> bounds: Readable<any>
height: Readable<number> height: Readable<number>
@ -108,7 +107,8 @@ export type Store = BaseStore &
Config.Store & Config.Store &
Conditions.Store & Conditions.Store &
Cache.Store & Cache.Store &
Viewport.Store Viewport.Store &
Notifications.Store
export const attachStores = (context: Store): Store => { export const attachStores = (context: Store): Store => {
// Atomic store creation // Atomic store creation

View File

@ -1,8 +1,17 @@
import { notifications as BBUINotifications } from "@budibase/bbui" import { notifications as BBUINotifications } from "@budibase/bbui"
import { derived } from "svelte/store" import { derived, Readable } from "svelte/store"
import { Store as StoreContext } from "." import { Store as StoreContext } from "."
export const createStores = (context: StoreContext) => { interface NotificationStore {
notifications: Readable<{
success: (message: string) => void
error: (message: string) => void
}>
}
export type Store = NotificationStore
export const createStores = (context: StoreContext): NotificationStore => {
const { notifySuccess, notifyError } = context const { notifySuccess, notifyError } = context
// Normally we would not derive a store in "createStores" as it should be // Normally we would not derive a store in "createStores" as it should be