Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/prevalence/src/prevalence.ts>Prevalence

Prevalence for Deno, like Prevayler.
Latest
class Prevalence
import { Prevalence } from "https://deno.land/x/prevalence@0.1.2/src/prevalence.ts";

TypeScript implementation for Deno of the Prevalence design pattern, as introduced by Klaus Wuestefeld in 1998 with Prevayler.

Saves periodical snapshots of the model, and journal of executed actions since last snapshot, using a Persister.

The Persister uses a Marshaller to serialize/deserialize the model and the journal.

Constructors

new
private
Prevalence(model: M, options: PrevalenceOptions<M>)

Properties

private
readonly
classes: SerializableClassesContainer
private
readonly
clock: Clock
private
readonly
persister: Persister<M>
model: M

Methods

execute<A extends Action<M>>(action: A): Promise<void>
snapshot(): Promise<void>

Static Methods

create<M extends Model<M>>(defaultInitialModel: M, options: Partial<PrevalenceOptions<M>>): Promise<Prevalence<M>>