Options
All
  • Public
  • Public/Protected
  • All
Menu

Class State<T>

Type parameters

  • T

Hierarchy

  • EventEmitter
    • State

Index

Constructors

constructor

Properties

Record

Record: ImmutableRecord.Factory<T>

StoresRecord

StoresRecord: ImmutableRecord.Factory<IStores<T>>

current

current: RecordOf<T>

stores

stores: RecordOf<IStores<T>>

Static defaultMaxListeners

defaultMaxListeners: number

Readonly Static errorMonitor

errorMonitor: unique symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: "change", listener: (state: RecordOf<T>, action?: string) => void): this
  • addListener(event: "change-for", listener: (state: RecordOf<T>, name: string, action?: string) => void): this
  • Parameters

    • event: "change"
    • listener: (state: RecordOf<T>, action?: string) => void
        • (state: RecordOf<T>, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • Optional action: string

          Returns void

    Returns this

  • Parameters

    • event: "change-for"
    • listener: (state: RecordOf<T>, name: string, action?: string) => void
        • (state: RecordOf<T>, name: string, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • name: string
          • Optional action: string

          Returns void

    Returns this

clear

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

fromJSON

  • fromJSON(json: IJSONObject): State

getCurrent

  • getCurrent(): RecordOf<T>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getStore

  • getStore<K>(name: K): Store<T, T[K]>

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: "change", listener: (state: RecordOf<T>, action?: string) => void): this
  • off(event: "change-for", listener: (state: RecordOf<T>, name: string, action?: string) => void): this
  • off(event: "change"): this
  • off(event: "change-for"): this
  • Parameters

    • event: "change"
    • listener: (state: RecordOf<T>, action?: string) => void
        • (state: RecordOf<T>, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • Optional action: string

          Returns void

    Returns this

  • Parameters

    • event: "change-for"
    • listener: (state: RecordOf<T>, name: string, action?: string) => void
        • (state: RecordOf<T>, name: string, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • name: string
          • Optional action: string

          Returns void

    Returns this

  • Parameters

    • event: "change"

    Returns this

  • Parameters

    • event: "change-for"

    Returns this

on

  • on(event: "change", listener: (state: RecordOf<T>, action?: string) => void): this
  • on(event: "change-for", listener: (state: RecordOf<T>, name: string, action?: string) => void): this
  • Parameters

    • event: "change"
    • listener: (state: RecordOf<T>, action?: string) => void
        • (state: RecordOf<T>, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • Optional action: string

          Returns void

    Returns this

  • Parameters

    • event: "change-for"
    • listener: (state: RecordOf<T>, name: string, action?: string) => void
        • (state: RecordOf<T>, name: string, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • name: string
          • Optional action: string

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event: "change" | "change-for"): this
  • Parameters

    • event: "change" | "change-for"

    Returns this

removeListener

  • removeListener(event: "change", listener: (state: RecordOf<T>, action?: string) => void): this
  • removeListener(event: "change-for", listener: (state: RecordOf<T>, name: string, action?: string) => void): this
  • Parameters

    • event: "change"
    • listener: (state: RecordOf<T>, action?: string) => void
        • (state: RecordOf<T>, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • Optional action: string

          Returns void

    Returns this

  • Parameters

    • event: "change-for"
    • listener: (state: RecordOf<T>, name: string, action?: string) => void
        • (state: RecordOf<T>, name: string, action?: string): void
        • Parameters

          • state: RecordOf<T>
          • name: string
          • Optional action: string

          Returns void

    Returns this

set

  • set(newState: RecordOf<T>, action?: string): State

setFor

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

toJS

  • toJS(): IJSONObject

toJSON

  • toJSON(): T

update

  • update(updateFn: (state: RecordOf<T>) => RecordOf<T>, action?: string): State
  • Parameters

    • updateFn: (state: RecordOf<T>) => RecordOf<T>
        • (state: RecordOf<T>): RecordOf<T>
        • Parameters

          • state: RecordOf<T>

          Returns RecordOf<T>

    • Optional action: string

    Returns State

updateFor

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc