Skip to content

dbrewer5/vue-composable

 
 

Repository files navigation

vue-composable

CircleCI Coverage Status npm version

Introduction

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.

Installing

# install with yarn
yarn add @vue/composition-api vue-composable

# install with npm
npm install @vue/composition-api vue-composable

Documentation

Check our documentation

Event

  • 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

MISC

Pagination

Promise

Web

  • Axios - reactive axios wrapper client
  • Fetch - reactive fetch wrapper
  • WebSocket - reactive WebSocket wrapper

Examples

Check out the examples folder or start hacking on codesandbox.

Edit Vue Composable Examples

NOTE

Currently only works with composition-api, when Vue3 gets release I will update to use the new reactive system (using @vue/reactivity)

Usage

<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>

License

MIT

About

Vue composition-api composable components

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.4%
  • JavaScript 3.6%