Skip to content
Fred Chien edited this page Nov 6, 2015 · 4 revisions

Sometimes, we have to use window object of browser to get window size, events and any kinds of information. Trying to access window object in isomorphic architecture is quite easy to crash, because such object does not exists on server-side. Lantern provide Window Extension for this purpose, to let developer do jobs that getting window size and listening to window event more easier and safe.

Window Store

This extension provides a Window store which is stored in Fluky framework, developer can get it for window information:

var win = this.flux.getState('Window');

Currently, Window store contains those properties which are defined as below:

  • width - window size
  • height - window height

The store will be updated when window status of browser is actually changed, so you can listen to it for watching with FLUX way:

this.flux.on('state.Window', Fluky.bindListener(this.onWindowChanged));
this.flux.off('state.Window', this.onWindowChanged);

Page Title

You can change page title by accessing Window store:

this.flux.dispatch('action.Window.setTitle', 'My Page');