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

Allow custom loading indicators #9

Open
reinink opened this issue Apr 16, 2019 · 4 comments

Comments

@reinink
Copy link
Collaborator

@reinink reinink commented Apr 16, 2019

Currently Inertia uses nprogress for its loading indicator. However, it would be nice to support other libraries. We'd simply have to expose this as a configuration option somehow.

For example:

new Vue({
  render: h => h(Inertia, {
    props: {
      component: app.dataset.component,
      props: JSON.parse(app.dataset.props),      
      resolveComponent: (component) => { ... },
      beforeVisit: () => { /* start loading indicator */ },
      afterVisit: () => { /* stop loading indicator */ },
    },
  }),
}).$mount(app)
@reinink

This comment has been minimized.

Copy link
Collaborator Author

@reinink reinink commented May 18, 2019

I actually think a better approach is to allow Inertia level customization directly via Inertia, and not through the adapters.

Inertia.beforeVisit(() => {}),
Inertia.afterVisit(() => {}),
Inertia.startProgress(() => {}),
Inertia.incrementProgress(() => {}),
Inertia.stopProgress(() => {}),
@MichaelDeBoey

This comment has been minimized.

Copy link
Contributor

@MichaelDeBoey MichaelDeBoey commented May 18, 2019

I do think we should also support this in some way or another via the adapters, since those are really a component mapping over the Inertia API

@reinink

This comment has been minimized.

Copy link
Collaborator Author

@reinink reinink commented May 18, 2019

I'm not sure I agree. There is nothing wrong with using Inertia directly (ie. Inertia.visit()), and we're really just talking about configuration here. To make every adapter responsible for this just means more work at the adapter level.

@MichaelDeBoey

This comment has been minimized.

Copy link
Contributor

@MichaelDeBoey MichaelDeBoey commented May 18, 2019

Just seems a bit weird to have the following code then:

import InertiaVue, { Inertia } from 'inertia-vue'
import Vue from 'vue'

Inertia.beforeVisit(() => {})
Inertia.afterVisit(() => {})
Inertia.startProgress(() => {})
Inertia.incrementProgress(() => {})
Inertia.stopProgress(() => {})

Vue.use(InertiaVue)

const app = document.getElementById('app')

new Vue({
  render: h => h(InertiaVue, {
    props: {
      initialPage: JSON.parse(app.dataset.page),
      resolveComponent: name => import(`@/Pages/${name}`).then(module => module.default),
    },
  }),
}).$mount(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.