UNPKG

@magicbell/core

Version:

Official MagicBell API wrapper

49 lines (48 loc) 2.02 kB
import Notification from '../models/Notification/index.js'; import NotificationStore from './NotificationStore.js'; import { NotificationCompareStrategy } from './strategy.js'; type StrategyComparator = (attribute: any, rule: any) => boolean; /** * A notification store with a context. Actions are executed taking into * consideration the context. * * @example * const store = new NotificationStoreWithContext({ read: true }); * store.fetch({ page: 2 }); */ export default class NotificationStoreWithContext extends NotificationStore { context: {}; strategy: NotificationCompareStrategy; constructor(context: any); /** * Add or remove a notification that changed. Changes can be tracked using the * `observe` or `observeKey` functions. * * @param notification Notification to add or remove to the store * @param stategy Function to test the notification against the context * @returns Whether the notification store was modified or not */ handleNotificationChange(notification: Notification, comparator?: StrategyComparator): boolean; /** * Remove a notification from the store if it does not match the context. * Deleted notifications are removed. * * @param notification Notification to remove * @param stategy Function to test the notification against the context */ removeUnlessMatchesContext(notification: Notification, comparator?: StrategyComparator): boolean; /** * Add a notification to the store if it matches the context. Deleted * notifications are not added. * * @param notification Notification to add * @param stategy Function to test the notification against the context */ addIfMatchesContext(notification: Notification, comparator?: StrategyComparator): boolean; fetch(queryParams?: {}, options?: { reset: boolean; }): Promise<void>; fetchNextPage(queryParams?: {}): Promise<void>; fetchAndReset(queryParams?: {}): Promise<void>; } export {};