How to use the nprogress/nprogress.start function in nprogress

To help you get started, we’ve selected a few nprogress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisvfritz / vue-enterprise-boilerplate / src / router / index.js View on Github external
router.beforeEach((routeTo, routeFrom, next) => {
  // If this isn't an initial page load...
  if (routeFrom.name !== null) {
    // Start the route progress bar.
    NProgress.start()
  }

  // Check if auth is required on this route
  // (including nested routes).
  const authRequired = routeTo.matched.some((route) => route.meta.authRequired)

  // If auth isn't required for the route, just continue.
  if (!authRequired) return next()

  // If auth is required and the user is logged in...
  if (store.getters['auth/loggedIn']) {
    // Validate the local user token...
    return store.dispatch('auth/validate').then((validUser) => {
      // Then continue if the token still represents a valid user,
      // otherwise redirect to login.
      validUser ? next() : redirectToLogin()
github cyklokoalicia / OpenSourceBikeShare / frontend / router / index.js View on Github external
router.beforeResolve((routeTo, routeFrom, next) => {
    // If this isn't an initial page load...
    if (routeFrom.name) {
        // Start the route progress bar.
        NProgress.start()
    }
    next()
})
github frandiox / vue-graphql-enterprise-boilerplate / src / router / index.js View on Github external
router.beforeEach(async (routeTo, routeFrom, next) => {
  // If this isn't an initial page load...
  if (routeFrom.name !== null) {
    // Start the route progress bar.
    NProgress.start()
  }

  if (['login', 'logout', '404'].includes(routeTo.name)) return next()

  // Check if session is valid and renew if necessary.
  // Fetch user asynchronously after checking session.
  const userPromise = checkSession().then(getCurrentUser)

  // If auth isn't required for the route (or nested routes),
  // just continue and don't wait for user object.
  if (!routeTo.matched.some(route => route.meta.authRequired)) return next()

  // Wait for user object to check permissions
  const user = await userPromise

  if (!user || user.role === 'TODO') {
github alexcasalboni / serverless-multi-region-client-demo / src / RegionSideBar.js View on Github external
writeValue(endpoint, key, value) {
      NProgress.start();
      const beforeTime = new Date();
      let afterTime = null;
      return fetch(`${endpoint}/${key}`, {
        method: 'POST',
        body: JSON.stringify({value: value}),
      })
        .then((response) => {
          NProgress.done();
          afterTime = new Date();
          return response.json()
        }).then((data) => {
          data.elapsedTime = afterTime.getTime() - beforeTime.getTime();
          return data;
        });
    }
github alexcasalboni / serverless-multi-region-client-demo / src / RegionSideBar.js View on Github external
readKey(endpoint, key) {
      NProgress.start();
      const beforeTime = new Date();
      let afterTime = null;
      return fetch(`${endpoint}/${key}`)
        .then((response) => {
          NProgress.done();
          afterTime = new Date();
          return response.json()
        }).then((data) => {
          data.elapsedTime = afterTime.getTime() - beforeTime.getTime();
          return data;
        });
    }