import { EventEmitter } from '@herbcaudill/eventemitter42'; import { type Action, type Graph } from 'graph/index.js'; import { type KeysetWithSecrets } from 'keyset/index.js'; import { type Hash, type Optional } from 'util/index.js'; import { type StoreOptions } from './StoreOptions.js'; /** * A CRDX `Store` is intended to work very much like a Redux store. * https://github.com/reduxjs/redux/blob/master/src/createStore.ts * * The only way to change the data in the store is to `dispatch` an action to it. There should only * be a single store in an application. */ export declare class Store> extends EventEmitter { private readonly user; private readonly context; private readonly initialState; private readonly reducer; private readonly resolver; private readonly validators?; private keyring; private graph; private state; constructor({ user, context, graph, rootPayload, initialState, reducer, validators, resolver, keys, }: StoreOptions); /** Returns the store's most recent state. */ getState(): S; /** Returns the current hash graph */ getGraph(): Graph; /** * Returns the current hash graph in serialized form; this can be used to rehydrate this * store from storage. * */ save(): Buffer; /** * Dispatches an action to be added to the hash graph. This is the only way to trigger a * state change. * * The `reducer` function provided when creating the store will be called with the current state * and the given `action`. Its return value will be considered the **next** state of the tree, * and any change listeners will be notified. * * @returns For convenience, the same action object that was dispatched. */ dispatch( /** * A Redux-style plain object representing what changed. An action must have a `type` property * which may not be `undefined`. It is a good idea to use string constants for action types. */ action: Optional, /** * Keys used to encrypt the action's payload. If not provided, the action will be encrypted * using the same keys as the previous action. */ keys?: KeysetWithSecrets): Optional; /** * Merges another graph (e.g. from a peer) with ours. * @param theirGraph * @returns this `Store` instance */ merge(theirGraph: Graph): void; /** * Validates the store's integrity, using the built-in validators (verify hashes, check * timestamps, etc.) as well as any custom validators provided by the application. */ validate(): import("validator/index.js").ValidationResult; private updateState; } type StoreEvents = { updated: (payload: { head: Hash[]; }) => void; }; export {}; //# sourceMappingURL=Store.d.ts.map