export
class

  AtomWatcher

implements

  {IDisposable}

template

  T

### Type parameters

- #### T

### Hierarchy

- AtomWatcher

### Implements

- IDisposable

## Index

### Constructors

- constructor

### Properties

- func
- funcText
- path
- target

### Methods

- dispose
- init
- toString

## Constructors

### constructor

- new AtomWatcher(target: T, path: PathList[] | function, onChanged: function, source?: any): AtomWatcher

- - Defined in src/core/AtomWatcher.ts:51

  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

- Defined in src/core/AtomWatcher.ts:39

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

- Defined in src/core/AtomWatcher.ts:41

### path

path: ObjectProperty[][]

- Defined in src/core/AtomWatcher.ts:43

### target

target: any

- Defined in src/core/AtomWatcher.ts:45

## Methods

### dispose

- dispose(): void

- Implementation of IDisposable.dispose

  - Defined in src/core/AtomWatcher.ts:122

  This will dispose and unregister all watchers

  memberof

    AtomWatcher

  #### Returns void

### init

- init(evaluate?: boolean): void

- - Defined in src/core/AtomWatcher.ts:147

  Initialize the path targets

  #### Parameters

  - ##### Optional evaluate: boolean

    if true, evaluate entire watch expression and run onChange method

  #### Returns void

### toString

- toString(): string

- - Defined in src/core/AtomWatcher.ts:113

  #### Returns string

Generated using TypeDoc