vue-observable-fn
v0.2.1
Published
Vue observable function
Downloads
13
Readme
Vue Observable Function
Example
<script setup>
import { useObservableFn } from 'vue-observable-fn'
const [submit, submission] = useObservableFn(async (foo, bar) => {
await new Promise((resolve) => setTimeout(resolve, 1000))
return { foo, bar }
})
</script>
<template>
<button type="button" @click="submit(1, 'hello')">submit</button>
<div v-if="submission.isPending">loading</div>
<div v-if="submission.isFulfilled">{{ submission.result }}</div>
<div v-if="submission.isRejected">{{ submission.error }}</div>
</template>