What is the best way to access Document
and Window
objects in ES6
/ Aurelia
framework? I did try accessing window
directly in my Aurelia code and it does seem to work, but is that the proper way or is there an Aurelia/ES6 way of doing that?
Specifically, I want to access properties like window.localStorage and window.sessionStorage. I'm just starting with Aurelia and ES6, so I'm a little noob on how to do this one though I would like to follow the standards.
Something like the following:
constructor() {
this.user = JSON.parse(window.sessionStorage.user || window.localStorage.user);
}
That code actually work in Aurelia, but is that correct to write it this way?