f / vue-wait

Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
MIT License
2k stars 101 forks source link

Accessible instance after registration #109

Closed SinanMtl closed 3 years ago

SinanMtl commented 3 years ago

With this PR, we can access the instance after registration.

  1. Prepare vue-wait in another file named wait.js
    
    import { createVueWait } from 'vue-wait'

const VueWait = createVueWait({ useVuex: false, registerComponent: true })

export const wait = VueWait.instance export default VueWait


2. Register vue-wait to app
```js
import { createApp } from 'vue'
import App from './App.vue'
import VueWait from './wait.js'

createApp(App).use(VueWait)
  1. After registration, you can use vue-wait's API in js files. For example;
    
    import { wait } from './wait.js' 

async function foo() { wait.start('foo')

await sendFoo()

wait.end('foo') }



Thus, you can create wait anywhere and can be use any place in your code.