This view model should be used with WindowService to create and open window.

This view model has `close` and `cancel` methods. `close` method will close the window and will resolve the given result in promise. `cancel` will reject the given promise.

example

       @Inject windowService: NavigationService
       var result = await
           windowService.openPage(
               ModuleFiles.views.NewWindow,
               {
                   title: "Edit Object",
                   data: {
                       id: 4
                   }
               });

       class NewTaskWindowViewModel extends AtomWindowViewModel{

           ....
           save(){

               // close and send result
               this.close(task);

           }
           ....

       }

export
class

  AtomWindowViewModel

extends

  {AtomViewModel}

### Hierarchy

- AtomViewModel
  - AtomWindowViewModel
    - MockConfirmViewModel

## Index

### Constructors

- constructor

### Properties

- app
- closeWarning
- postInit
- title
- windowName

### Accessors

- errors
- isReady
- isValid
- parent

### Methods

- cancel
- close
- dispose
- init
- onPropertyChanged
- onReady
- refresh
- registerDisposable
- resetValidations
- runAfterInit
- setupWatch

## Constructors

### constructor

- new AtomWindowViewModel(app: App): AtomWindowViewModel

- Inherited from AtomViewModel.constructor

  - Defined in src/view-model/AtomViewModel.ts:158

  #### Parameters

  - ##### app: App

  #### Returns AtomWindowViewModel

## Properties

### app

app: App

Inherited from AtomViewModel.app

- Defined in src/view-model/AtomViewModel.ts:160

### closeWarning

closeWarning: string

- Defined in src/view-model/AtomWindowViewModel.ts:49

### postInit

postInit: Function[]

Inherited from AtomViewModel.postInit

- Defined in src/view-model/AtomViewModel.ts:68

### title

title: string

- Defined in src/view-model/AtomWindowViewModel.ts:47

### windowName

windowName: string

- Defined in src/view-model/AtomWindowViewModel.ts:62

windowName will be set to generated html tag id, you can use this to mock AtomWindowViewModel in testing.

When window is closed or cancelled, view model only broadcasts `atom-window-close:${this.windowName}`, you can listen for such message.

type

  {string}

memberof

  AtomWindowViewModel

## Accessors

### errors

- get errors(): Array<object>

- Inherited from AtomViewModel.errors

  - Defined in src/view-model/AtomViewModel.ts:83

  #### Returns Array<object>

### isReady

- get isReady(): boolean

- Inherited from AtomViewModel.isReady

  - Defined in src/view-model/AtomViewModel.ts:79

  If it returns true, it means all pending initializations have finished

  #### Returns boolean

### isValid

- get isValid(): boolean

- Inherited from AtomViewModel.isValid

  - Defined in src/view-model/AtomViewModel.ts:133

  Returns true if all validations didn't return any error. All validations are decorated with @Validate decorator.

  #### Returns boolean

### parent

- get parent(): AtomViewModel
- set parent(v: AtomViewModel): void

- Inherited from AtomViewModel.parent

  - Defined in src/view-model/AtomViewModel.ts:110

  Returns parent AtomViewModel if it was initialized with one. This property is also useful when you open an popup or window. Whenever a popup/window is opened, ViewModel associated with the UI element that opened this popup/window becomes parent of ViewModel of popup/window.

  #### Returns AtomViewModel

- Inherited from AtomViewModel.parent

  - Defined in src/view-model/AtomViewModel.ts:113

  Returns parent AtomViewModel if it was initialized with one. This property is also useful when you open an popup or window. Whenever a popup/window is opened, ViewModel associated with the UI element that opened this popup/window becomes parent of ViewModel of popup/window.

  #### Parameters

  - ##### v: AtomViewModel

  #### Returns void

## Methods

### cancel

- cancel(): Promise<boolean>

- - Defined in src/view-model/AtomWindowViewModel.ts:81

  This will return true if this view model is safe to cancel and close

  #### Returns Promise<boolean>

### close

- close(result?: any): void

- - Defined in src/view-model/AtomWindowViewModel.ts:74

  This will broadcast `atom-window-close:windowName`. WindowService will close the window on receipt of such message and it will resolve the promise with given result.

       this.close(someResult);

  memberof

    AtomWindowViewModel

  #### Parameters

  - ##### Optional result: any

  #### Returns void

### dispose

- dispose(): void

- Inherited from AtomViewModel.dispose

  - Defined in src/view-model/AtomViewModel.ts:239

  dispose method will be called when attached view will be disposed or when a new view model will be assigned to view, old view model will be disposed.

  memberof

    AtomViewModel

  #### Returns void

### init

- init(): Promise<any>

- Inherited from AtomViewModel.init

  - Defined in src/view-model/AtomViewModel.ts:230

  Put your asynchronous initialization here

  memberof

    AtomViewModel

  #### Returns Promise<any>

### Protected onPropertyChanged

- onPropertyChanged(name: string): void

- Inherited from AtomViewModel.onPropertyChanged

  - Defined in src/view-model/AtomViewModel.ts:307

  #### Parameters

  - ##### name: string

  #### Returns void

### Protected onReady

- onReady(): void

- Inherited from AtomViewModel.onReady

  - Defined in src/view-model/AtomViewModel.ts:269

  #### Returns void

### refresh

- refresh(name: string): void

- Inherited from AtomViewModel.refresh

  - Defined in src/view-model/AtomViewModel.ts:219

  Refreshes bindings associated with given property name

  #### Parameters

  - ##### name: string

    name of property

  #### Returns void

### Protected registerDisposable

- registerDisposable(d: IDisposable): IDisposable

- Inherited from AtomViewModel.registerDisposable

  - Defined in src/view-model/AtomViewModel.ts:263

  Register a disposable to be disposed when view model will be disposed.

  memberof

    AtomViewModel

  #### Parameters

  - ##### d: IDisposable

  #### Returns IDisposable

### resetValidations

- resetValidations(resetChildren?: boolean): void

- Inherited from AtomViewModel.resetValidations

  - Defined in src/view-model/AtomViewModel.ts:168

  Resets validations and all errors are removed.

  #### Parameters

  - ##### Default value resetChildren: boolean = true

    reset child view models as well. Default is true.

  #### Returns void

### runAfterInit

- runAfterInit(f: function): void

- Inherited from AtomViewModel.runAfterInit

  - Defined in src/view-model/AtomViewModel.ts:184

  Runs function after initialization is complete.

  #### Parameters

  - ##### f: function

    function to execute

    - - (): void

      - #### Returns void

### Protected setupWatch

- setupWatch(ft: string[][] | function, proxy?: function, forValidation?: boolean, name?: string): IDisposable

- Inherited from AtomViewModel.setupWatch

  - Defined in src/view-model/AtomViewModel.ts:289

  Execute given expression whenever any bindable expression changes in the expression.

  For correct generic type resolution, target must always be `this`.

       this.setupWatch(() => {
           if(!this.data.fullName){
               this.data.fullName = `${this.data.firstName} ${this.data.lastName}`;
           }
       });

  template

    T

  memberof

    AtomViewModel

  #### Parameters

  - ##### ft: string[][] | function

  - ##### Optional proxy: function

    - - (...v: any[]): void

      - #### Parameters

        - ##### Rest ...v: any[]

        #### Returns void

  - ##### Optional forValidation: boolean

  - ##### Optional name: string

  #### Returns IDisposable

Generated using TypeDoc