LocalStorageEntity

class LocalStorageEntity<T, I>(resource: Resource<T, I>, prefix: String) : EntityRepository<T, I>

provides crud-functions for localStorage to deal with a single entity

Parameters

resource

definition of the Resource to use

prefix

prefix used for prepending to the keys

Constructors

LocalStorageEntity
Link copied to clipboard
js
fun <T, I> LocalStorageEntity(resource: Resource<T, I>, prefix: String)
definition of the Resource to use

Functions

addOrUpdate
Link copied to clipboard
js
open suspend override fun addOrUpdate(entity: T): T
adds or updates the serialized entity to localStorage using prefix and id defined in resource
delete
Link copied to clipboard
js
open suspend override fun delete(entity: T)
deletes the entity in localStorage
load
Link copied to clipboard
js
open suspend override fun load(id: I): T
loads an entity from localStorage using prefix and id defined in resource