Run function one time

how to run function one time when app is open and the next time when app is open then function is not called.

Hi Alisax,

You can take advantage of localStorage get rid of one time app initializer function.

Simply create “app.data” or whatever name localstorage, when app will run for first time it will check initialize key exist in that app.data storage, if it null then do one time setup code.

initApp() {
  let local = new LocalStorage("app.data");
  
  local.get("initialize").then((result) => {
      if(result == null) {
          local.set("initialize","completed");
          console.log("Do your one time initializing code");
      } else {
          console.log("code which will not call first time, called for subsequent app view")
      }
  })
}

hi itsmemyk
Great. Thank you! That was surprisingly easy.
Again Thank You very much … :slight_smile: