Data SourcesReferenceLocalStoragePart

LocalStoragePart Class

Extends KeyValueSourcePart and allows interaction with a particular key in the browser’s local storage. It provides methods for retrieving, setting, and observing the value associated with the given key

@template T = string | undefined
The type of the value stored in local storage. Defaults to string | undefined

API

class LocalStoragePart<T = string | undefined> extends KeyValueSourcePart<T> {
  readonly $: Observable<T>;
  constructor(key: string);
  get(): T;
  set(value: T): void;
  remove(): void;
}

Example

import {LocalStoragePart} from '@bitfiber/rx';
 
const lsPart = new LocalStoragePart('key');