Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StoreElement<T>

Internal representation of every object inside of the extension storage.

If you want to create a StoreElementProxy directly, call StoreElement.create.

see

Store which manages these objects.

StoreElement itself is only used for "child" objects.

see

StoreElementRoot for the root.

see

StoreElementProxy for a more accurate representation of the values returned by Store

Type parameters

  • T

Hierarchy

Index

Constructors

Protected constructor

Properties

Protected _container

_container: Indexable<StoreElement<T[keyof T]> | T[keyof T]>

Protected _root

_root: StoreElementRoot<any>

onUpdate$

onUpdate$: Subject<this>

Observable which pushes a new value when anything changes.

see

StoreElement.value$ which does the same but always pushes the current value first.

value$

value$: BehaviorSubject<this>

Like StoreElement.onUpdate$ but a BeahviourSubject. As such it always pushes the current value when you subscribe to it.

Accessors

isArray

  • get isArray(): boolean
  • Find out whether this store element represents an array instead of an object.

    Returns boolean

rawValue

  • get rawValue(): T
  • Return the "raw" value such as the one that was used to create this element. This recursively traverses the element tree and converts the nested store elements to their raw value.

    This returns a copy of the value, not the original one.

    Returns T

Methods

deleteProperty

  • deleteProperty(key: string | number): void
  • Parameters

    • key: string | number

    Returns void

equals

  • equals(other: T): boolean
  • Check whether the StoreElement is equal to a raw value. This is not a comparator between StoreElement. It is used by StoreElement.update to check whether something has changed.

    example
    
    // storeEl is a StoreElement!
    
    // this is a tautology!
    storeEl.equals(storeEl.rawValue);

    Parameters

    • other: T

    Returns boolean

get

  • get(key: string | number): any
  • Parameters

    • key: string | number

    Returns any

getOrSetDefault

  • getOrSetDefault<V>(key: string | number, defaultValue: V): V | StoreElementProxy<V>
  • Get the value of key or set it to the provided default value if it doesn't exist.

    Type parameters

    • V

    Parameters

    • key: string | number
    • defaultValue: V

    Returns V | StoreElementProxy<V>

getOwnPropertyDescriptor

  • getOwnPropertyDescriptor(p: string | number): PropertyDescriptor | undefined
  • Parameters

    • p: string | number

    Returns PropertyDescriptor | undefined

has

  • has(key: any): boolean
  • Parameters

    • key: any

    Returns boolean

ownKeys

  • ownKeys(): string[]

save

  • save(): Promise<void>

set

  • set(key: string | number, value: any): void
  • Parameters

    • key: string | number
    • value: any

    Returns void

setDefaults

  • setDefaults(defaults: T): void
  • Provide some default values for this element. If a key already exists it is skipped.

    This does not trigger StoreElement.save!

    Parameters

    • defaults: T

    Returns void

Protected setValueSelf

  • setValueSelf(value: T): void

triggerSave

  • triggerSave(): void

update

  • update(newValue: T): void
  • Receive a new value and apply it to this element. This is not a method you should use! It is exposed for Store to apply changes to this element.

    see

    StoreElement.setDefaults for a way to set defaults.

    Parameters

    • newValue: T

    Returns void

Static create

Generated using TypeDoc