operator icon indicating copy to clipboard operation
operator copied to clipboard

Route lifecycle

Open bojanvidanovic opened this issue 4 years ago • 1 comments

Hi,

I think it would be very useful if the route handler could have an asynchronous lifecycle out of the box.

Greate little lib, by the way, thanks.

bojanvidanovic avatar Jan 03 '21 14:01 bojanvidanovic

At the moment the only way seems to use some ugly logical methods, like:

{
  path: '/blog/:post',
  handler () {
    let loaded = false;

    app.on('after', () => {
      if (!loaded) {
         loaded = true;
         Slider.init();
      }
    })
  }
}

But having something like: state.beforeLoad, state.afterLoad would come in very handy for manipulating DOM and destroying events.

bojanvidanovic avatar Jan 22 '21 12:01 bojanvidanovic