Options
All
  • Public
  • Public/Protected
  • All
Menu

A simple store to hold and manipulate a generic state

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new State(initialState: any): State
  • Inject the initial state object

    Parameters

    • initialState: any

    Returns State

Properties

Protected _state

_state: PlainObject<any>

The registered translations on this instance

Methods

destroy

  • destroy(): void
  • Destroys the internal state object

    Returns void

get

  • get(key: string | string[], fallback?: any): any
  • Returns the value of the initial state

    Parameters

    • key: string | string[]
    • Optional fallback: any

    Returns any

getAll

  • getAll(): PlainObject<any>
  • Returns all key and value pairs that are currently inside the state

    Returns PlainObject<any>

has

  • has(key: string | string[]): boolean
  • Returns true if a certain key exists in the state

    Parameters

    • key: string | string[]

    Returns boolean

hasValue

  • hasValue(key: string | string[], includeZero?: boolean): boolean
  • Similar to "has" but also checks if the value on a key is "empty". If the value is considered empty this method will return false Empty values are: NULL, undefined, 0, "", " ", {}, [] and empty Maps and Sets

    Parameters

    • key: string | string[]
    • Optional includeZero: boolean

      By default zero (0) is not seen as "empty" if you set this to true, it will be, tho

    Returns boolean

Generated using TypeDoc