exome
import {
Exome,
subscribe,
update,
updateAll,
onAction,
getExomeId,
setExomeId,
addMiddleware,
runMiddleware,
type Middleware
} from "exome";
class Exome
Class that every store extends from.
class Exome {
constructor()
}
function subscribe
Subscribe to store instance update events.
function subscribe<T extends Exome>(
store: T,
callback: (store: T) => void,
): Unsubscribe;
function update
Sends update event to specific store instance.
function update(store: Exome): void;
function updateAll
Sends update event to all existing store instances.
function updateAll(): void;
function onAction
Listens to specific actions for all instances of particular store.
function onAction<T extends Exome>(
Target: new () => T,
action: "NEW" | "LOAD_STATE" | keyof T | null,
callback: (
instance: T,
action: "NEW" | "LOAD_STATE" | keyof T,
payload: any[],
error?: Error
) => void,
type?: "before" | "after",
): Unsubscribe;
function getExomeId
Gets unique id of specific store instance.
function getExomeId(store: Exome): string;
function setExomeId
Sets custom id to specific store instance.
function setExomeId(store: Exome, id: string): string;
function addMiddleware
Listens to middleware calls for any store instance.
function addMiddleware(fn: Middleware): Unsubscribe;
function runMiddleware
Triggers middleware for particular store instance to be called. When return function gets called, it maks that the middleware action was completed with or without errors.
function runMiddleware(
instance: Exome,
action: string,
payload: any[],
): (error?: Error) => void;
type Middleware = (
instance: Exome,
action: string,
payload: any[],
) => void | ((error?: Error) => void);