promise-vue
v1.0.1
Published
Ultra simple component to work with Promise.
Downloads
34
Maintainers
Readme
promise-vue
Ultra simple component to work with Promise.
Installation
It may be installed as npm package
npm i promise-vue
import VuePromiseComponent from 'promise-vue'
then register as component
components: {
"promise-vue": VuePromiseComponent,
}
How to use
In promise You have 3 state
- pendding
- resolved
- error
So all you need it pass promise to promise-vue
component
it looks like :
<promise-vue :delay="delay" :promise="examplePromise" tag="div">
<template v-slot:pendding>
<div>Loadding...</div>
</template>
<template v-slot:resolved="data">
<pre>{{ data }}</pre>
</template>
<template v-slot:error="error">
<pre>Opss... {{ error }}</pre>
</template>
</promise-vue>
Slots
v-slot:pendding
: shows when promise pending/loadingv-slot:resolved="data"
: scoped slot with received datav-slot:error="error"
: scoped slot with error data
Props
promise
: just promisetag
: tag to wrap by default - divdelay
: delay of minimum time to show loading slot by default - 0
P.S. real example in src\Example.vue