Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Const computed

  • computed(target: any, name: string, propDescr: PropertyDescriptor): void
  • Decorator function for defining "get" properties or functions retuning a value so that this value will automatically recalculated if any triggers on which this value depends have their values changed. WHen this happens, the watcher objects attached to this computed value will be notified to respond.

    Parameters

    • target: any
    • name: string
    • propDescr: PropertyDescriptor

    Returns void

Const createComputedTrigger

  • Creates a computed trigger object whose value is calculated by the given function or get accessor.

    Type parameters

    • T = any

      Type of the computed value.

    Parameters

    • func: NoneTypeFunc<T>

      Function, method or get accessor that produces the computed value.

    • Optional thisArg: any

      Optional this value to use when invoking the computing function.

    Returns ITrigger<T>

    Trigger object that will trigger changes only when the computed value changes.

Const createTrigger

  • createTrigger<T>(v?: T, depth?: number): ITrigger<T>
  • Creates a trigger object of the given depth with the given initial value. Triggers fire events when their value changes. They also work in conjunction with watchers (see createWatcher) and notify watchers when the trigger's value is read.

    The depth parameter determines how many levels of nested properties of arrays, maps, sets and objects should trigger read and write events. If the depth is 0, changing nested properties doesn't cause the trigger to fire - only changing the property itself does. If the depth is undefined, arrays, objects, maps and sets get the depth of 1, meaning that operations that add or remove items will trigger events, but modifications to the items will not. The depth parameter is ignored for primitive types.

    Type parameters

    • T = any

      Type of the trigger value.

    Parameters

    • Optional v: T

      Optional initial value

    • Optional depth: number

      Depth of the trigger, which determines how many levels of nested properties of arrays, maps, sets and objects should trigger changes. Ignored for primitive types.

    Returns ITrigger<T>

    ITrigger through which the value can be set and retrieved.

Const createWatcher

  • createWatcher<T>(func: T, responder: NoneVoidFunc, funcThis?: any, responderThis?: any): IWatcher<T>
  • Creates a watcher function with the same signature as the given regular function. When the watcher function is invoked it invokes the original function and it notices all trigger objects that were read during its execution. When any of these trigger objects have their values changed, the responder function will be called.

    Type parameters

    • T: AnyAnyFunc

      Type (signature) of the function to be watched.

    Parameters

    • func: T

      Function to be watched

    • responder: NoneVoidFunc

      Function to be invoked when values of the trigger objects encountered during the original function's last execution change.

    • Optional funcThis: any

      Optional value of "this" that will be used to call the original function.

    • Optional responderThis: any

      Optional value of "this" that will be used to call the responder function. If this value is undefined, the "this" value for the original function will be used.

    Returns IWatcher<T>

    The callable IWatcher interface, which represent a function with the same sigature as the original function. In addition, the returned function has the dispose method, which must be called when the watcher is not needed anymore.

Const enterMutationScope

  • enterMutationScope(): void
  • Increments mutation scope reference count

    Returns void

Const exitMutationScope

  • exitMutationScope(): void
  • Decrements mutation scope reference count. If it reaches zero, notifies all deferred watchers.

    Returns void

Const trigger

  • trigger(targetOrDepth: any, name?: string): any
  • Decorator function for defining properties so that changing their value will any watcher objects attached to them to respond. The form @trigger designates a default trigger decorator, whose depth will be assigned depending on the value type: Shallow for arrays, maps and sets and Deep for objects. The form @trigger(n) designates a trigger decorator factory with the specified depth.

    Parameters

    • targetOrDepth: any
    • Optional name: string

    Returns any