UNPKG

@snipsonian/observable-state

Version:

Observable-state snippets (redux-like)

26 lines (25 loc) 1.39 kB
import { ITriggerParentNotifications } from './extendNotificationsToTrigger'; export interface IStateObserverManager<StateChangeNotificationKey> { registerObserver: (props: IRegisterStateObserverProps<StateChangeNotificationKey>) => IStateObserver<StateChangeNotificationKey>; unRegisterObserver: (observer: IStateObserver<StateChangeNotificationKey>) => void; notifyObserversOfStateChanges: (props: INotifyObserversOfStateChangesProps<StateChangeNotificationKey>) => void; } export interface IRegisterStateObserverProps<StateChangeNotificationKey> { observerName: string; notificationsToObserve: StateChangeNotificationKey[]; onNotify: (props: IStateObserverNotifyProps<StateChangeNotificationKey>) => void; } export interface IStateObserver<StateChangeNotificationKey> { id: number; observerName: string; notify: (props: IStateObserverNotifyProps<StateChangeNotificationKey>) => void; } export interface IStateObserverNotifyProps<StateChangeNotificationKey> { notifications: StateChangeNotificationKey[]; } interface INotifyObserversOfStateChangesProps<StateChangeNotificationKey> { notificationsToTrigger: StateChangeNotificationKey[]; triggerParentNotifications: ITriggerParentNotifications; } export default function createStateObserverManager<StateChangeNotificationKey>(): IStateObserverManager<StateChangeNotificationKey>; export {};