Skip to content
ts
import { LocalResource } from '@trail-run/core/reactive/storage-resource';

Function: LocalResource()

ts
function LocalResource(id): ClassDecorator;

Defined in: src/reactive/storage-resource.ts:28

Decorator which transforms a class into a StorageResource persisted in localStorage.

LocalResources must either be singletons or expect all instances to share state unless a primary key function is provided.

When a primary key function is provided, each instance will have its own persisted data based on the key generated by the function.

The function will be called once per instance during initialization to determine the unique ID for that instance.

Parameters

id

string | KeyFn

Returns

ClassDecorator

Released under the MIT License.