uralsjs-reactive-storage
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

uralsjs-reactive-storage

Reactive storages types and examples

API

/**
 * Abstract type for keepeing data as id-value-pair on generic types
 */
export type Rec<M, Id> = {
    id: Id,
    model: M
};

/**
 * Abstract type of setId function used in storages
 */
export type SetIdFunc<Id> = (keepedIds: Id[]) => Id;

/**
 * Reactive storage abstract type
 */
export type ReactiveStorage<M, Id> = {
    readAll(): Rec<M, Id>[],
    reinit(data: M[]): void,
    setReactiveFunc(renderFunc: (recs: Rec<M, Id>[]) => void): void,
    triggerReactiveFunc(): void
};

/***
 * Storage keeps data as numeric-id Recs with auto-increment Id generation function
 */
export class IncrNumReactiveStorage<M> implements ReactiveStorage<M, number>
{...};

/**
 * Storage keeps only one record with null-id
 */
export class SoloDefReactiveStorage<M> implements ReactiveStorage<M, null>
{...};

Author

Anatoly Starodubtsev tostar74@mail.ru

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i uralsjs-reactive-storage

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

18.7 kB

Total Files

22

Last publish

Collaborators

  • pantagruel74