Svuick

Packages Guides

@svuick/store API


debounce()

  • Type

    debounce<T>(store: Readable<T>, delay?: number): Readble<T>

throttle()

  • Type

    throttle<T>(store: Readable<T>, delay?: number): Readble<T>

readonly()

  • Type

    readonly<T>(store: Readable<T>): Readble<T>

persistentStore()

  • Type

    type PersistentStorageAdapter = {
      getItem: (key: string) => string | null;
      setItem: (key: string, value: string) => void;
    }
    persistentStore<T>(
      key: string,
      value: T,
      storage: PersistentStorageAdapter,
      start: StartStopNotifier<T>
    ): Writable<T>

localStore() & sessionStore()

  • Type

    localStore<T>(key: string, value: T, start: StartStopNotifier<T>): Writable<T>
    sessionStore<T>(key: string, value: T, start: StartStopNotifier<T>): Writable<T>
  • Details

    localStore saves the data to localStorage and subscribes to the storage event.

    sessionStore saves the data to sessionStorage.


undoRedo()

  • Type

    type UndoRedoStore<T extends JsonType> = Readable<T> & {
    	set(value: T): void;
    	undo(): void;
    	redo(): void;
    };
    
    undoRedo<T extends JsonType>(store: Writable<T>): UndoRedoStore<T>

undoRedoAction()

  • Type

    type UndoRedoActionStore<T> = Readable<T> & {
    	doAction(action: Action<T>): void;
    	undo(): void;
    	redo(): void;
    };
    
    undoRedoAction<T>(store: Writable<T>): UndoRedoActionStore<T>

mousePosition()

  • Type

    const mousePosition: Readable<{
    	x: number;
    	y: number;
    }>;
Released under the MIT License.
Copyright © 2022-present David Plugge