Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AtomWatcher<T>

export
class

AtomWatcher

implements

{IDisposable}

template

T

Type parameters

  • T

Hierarchy

  • AtomWatcher

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • new AtomWatcher(target: T, path: PathList[] | function, onChanged: function, source?: any): AtomWatcher
  • Creates an instance of AtomWatcher.

     let w = new AtomWatcher(this, x => x.data.fullName = `${x.data.firstName} ${x.data.lastName}`);

    You must dispose w in order to avoid memory leaks. Above method will set fullName whenever, data or its firstName,lastName property is modified.

    AtomWatcher will assign null if any expression results in null in single property path.

    In order to avoid null, you can rewrite above expression as,

     let w = new AtomWatcher(this,
                 x => {
                     if(x.data.firstName && x.data.lastName){
                       x.data.fullName = `${x.data.firstName} ${x.data.lastName}`
                     }
                 });
    memberof

    AtomWatcher

    Parameters

    • target: T

      Target on which watch will be set to observe given set of properties

    • path: PathList[] | function

      Path is either lambda expression or array of property path to watch, if path was lambda, it will be executed when any of members will modify

    • onChanged: function

      This function will be executed when any member in path is updated

        • (...v: any[]): any
        • Parameters

          • Rest ...v: any[]

          Returns any

    • Optional source: any

    Returns AtomWatcher

Properties

func

func: function

If path was given as an array of string property path, you can use this func that will be executed when any of property is updated.

You must manually invoke evaluate after setting this property.

memberof

AtomWatcher

Type declaration

    • (...values: any[]): any
    • Parameters

      • Rest ...values: any[]

      Returns any

funcText

funcText: string

path

path: ObjectProperty[][]

target

target: any

Methods

dispose

  • dispose(): void

init

  • init(evaluate?: boolean): void
  • Initialize the path targets

    Parameters

    • Optional evaluate: boolean

      if true, evaluate entire watch expression and run onChange method

    Returns void

toString

  • toString(): string

Generated using TypeDoc