Options
All
  • Public
  • Public/Protected
  • All
Menu

This class is a super simple state storage object. It is designed as a super lightweight alternative to vuex in smaller applications.

Hierarchy

  • Store

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Store(internalInitialState: PlainObject<any>, initialState?: Function): Store

Properties

Protected _store

_store: StoreVue

The internal, reactive storage object

Protected _unbinders

_unbinders: Map<Function, Function>

A list of callbacks used to destroy previously bound watchers

Methods

bind

  • Used to watch a certain store property for changes. Works in the same way your normal vue watchers work, the callback receives two values, the first is the new the second the previous value.

    Parameters

    • key: string

      The key of the property to watch

    • callback: StoreWatcher

      The callback to execute when a property changes

    • Optional options: WatchOptions

      Allows setting additional options for your watcher.

    Returns Store

get

  • get(key: ListPath, defaultValue?: any): any
  • Returns the value of a certain storage key, or the default value if it does not exist

    Parameters

    • key: ListPath

      The name of the stored value to extract

    • Optional defaultValue: any

      An optional default value to return if the given key was not found

    Returns any

getRaw

  • getRaw(): PlainObject<any>

getRawVue

  • getRawVue(): any
  • Returns the internal vue instance we use as reactive store Note: be careful with this, or you can break things quite easily.

    Returns any

has

  • has(key: ListPath): boolean

set

  • set(key: string, value: any): Store
  • This is used to update or set the value of a certain key in the store

    Parameters

    • key: string

      The name of the stored value to set

    • value: any

      The value to set for the given key

    Returns Store

unbind

  • Used to unbind a previously bound callback from watching a property.

    Parameters

    • key: string

      The key of the property to unbind the given callback from

    • callback: StoreWatcher

      The callback to unbind from watching a property.

    Returns Store

watch

Generated using TypeDoc