nativescript - How to set observable properties async in typescript? -


i have couple of properties fetched asynchronously. bind result of these properties view in application. however, get properties see view model's variables null. how can bind them after result has arrived? in code below, useremail , appversion null/undefined in respective functions.

export class accountviewmodel extends observable {     private _useremail : email;     private _appversion : string;      constructor() {         super();          appversion.getversionname().then(             (result) =>             {                 this._appversion = result;                 console.log(this._appversion);             });          firebase.getcurrentuser().then(             (result) => {                 this._useremail = new email(result.email);             });     }      useremail(): string {         return this._useremail != null ? this._useremail.value : "";     }      appversion(): string {         return this._appversion;     }      public logout() {         firebase.logout().then((result) => {             navigator.navigateto({                 modulename : "views/register/register",                 backstackvisible : false,                 clearhistory : true             })         }).catch((error) => {             dialogs.alert({                 title: "error",                 message: "a system error occurred trying logout.",                 okbuttontext: "ok"             });         });     } } 

the observable class has notifypropertychange method :)

export class accountviewmodel extends observable {     private _appversion : string;      constructor() {         super();          appversion.getversionname().then((result) => {             this._appversion = result;             this.notifypropertychange("appversion", this._appversion);         });     }      appversion() : string {         return this._appversion;     }      public logout() {         firebase.logout().then((result) => {             navigator.navigateto({                 modulename : "views/register/register",                 backstackvisible : false,                 clearhistory : true             })         }).catch((error) => {             dialogs.alert({                 title: "error",                 message: "a system error occurred trying logout.",                 okbuttontext: "ok"             });         });     } } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -