vue-composable
is out-of-box ready to use composition-api generic components, eg: useFetch
100% typescript based composable components and full type support out-of-box.
# install with yarn
yarn add @vue/composition-api vue-composable
# install with npm
npm install @vue/composition-api vue-composable
Check our documentation
- Event - Attach event listener to a DOM element
- Mouse Move - Attach
mousemove
listener to a DOM element - Resize - Attach
resize
listener to a DOM element - Scroll - Attach
scroll
listener to a DOM element
- localStorage - Reactive access to a
localStorage
- Pagination - Generic reactive pagination controls
- Array Pagination - Array pagination
- Promise -
Promise
reactive resolve and reject - Cancellable Promise - Allow to cancel promises
- Retry - Provides functionality to retry
promise
- Axios - reactive
axios
wrapper client - Fetch - reactive
fetch
wrapper - WebSocket - reactive
WebSocket
wrapper
Check out the examples folder or start hacking on codesandbox.
Currently only works with composition-api, when Vue3 gets release I will update to use the new reactive system (using @vue/reactivity)
<template>
<div>
<p>page {{ currentPage }} of {{ lastPage }}</p>
<p>
<button @click="prev">prev</button>
<button @click="next">next</button>
</p>
<ul>
<li v-for="n in result" :key="n">
{{ n }}
</li>
</ul>
</div>
</template>
<script>
import { useArrayPagination } from "vue-composable";
export default {
setup() {
const array = new Array(1000).fill(0).map((_, i) => i);
const { result, next, prev, currentPage, lastPage } = useArrayPagination(
array,
{
pageSize: 3
}
);
return { result, next, prev, currentPage, lastPage };
}
};
</script>