question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add beforeUpdate to route config

See original GitHub issue

What problem does this feature solve?

Since for now we can’t handle lazy loading components without losing access to navigation hooks build in components we should give equal API on router config level. For now we can only add beforeEnter route guard. It would be usefull if we had beforeUpdate guard too.

Problem with lazy loading components described here: https://github.com/vuejs/vue-router/issues/2830

What does the proposed API look like?

const router = new VueRouter({
  routes: [
    {
      path: '/foo',
      component: Foo,
      beforeUpdate: (to, from, next) => {
        // ...
      }
    }
  ]
})

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
posvacommented, Jun 28, 2019

Thanks for the proposal but regarding hooking into navigation cycle to show loading experience, this won’t add anything to hook on. beforeRouteUpdate is specific to components because we are on the component and have access to this. You can already write the guard somewhere and pass it to the component by importing it:

import { checkIdAccess } from '@/guards'

export default {
  beforeRouteEnter: checkIdAccess,
  beforeRouteUpdate: checkIdAccess,
}

Since for now we can’t handle lazy loading components without losing access to navigation hooks build in components we should give equal API on router config level.

This is untrue and we already talked about it in #2830

3reactions
Mighty683commented, Jun 28, 2019

Beside lazy loading why we need component to simply guard route update? Now we can guard enter to path without using component to do this job why not update?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigation Guards | Vue Router
You can add the following options to route components: ... The beforeRouteEnter guard does NOT have access to this , because the guard...
Read more >
Update VueJs component on route change - Stack Overflow
I can access the beforeEach hook in the routing configuration. Is there a way I can target my component specifically and change one...
Read more >
Form.BeforeUpdate event (Access) - Microsoft Learn
The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (1) cancels the BeforeUpdate event. Remarks.
Read more >
Back-end customization - Strapi Developer Docs
All elements of Strapi's back end, like routes, policies, middlewares, controllers, services, models, requests, responses, and webhooks, can be customized.
Read more >
Field Service Custom Triggers - Salesforce Developers
Calendar Sync's settings are located in Field Service settings page. From the settings page, ... Before Update: (content is the same as Before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found