Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route lifecycle #23

Open
bojanvidanovic opened this issue Jan 3, 2021 · 1 comment
Open

Route lifecycle #23

bojanvidanovic opened this issue Jan 3, 2021 · 1 comment

Comments

@bojanvidanovic
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant