How to use vue-composable - 8 common examples

To help you get started, we’ve selected a few vue-composable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pikax / vue-composable / docs / .vuepress / components / RetryExample.vue View on Github external
const retryDelay = n => {
      switch (mode.value) {
        case "delay":
          return delay.value;
        case "backoff":
          return exponentialDelay(n);
      }
    };
github pikax / vue-composable / docs / .vuepress / components / ArrayPaginationExample.vue View on Github external
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 };
  }
};
github pikax / vue-composable / docs / .vuepress / components / EventExample.vue View on Github external
setup(_){
    const elref = ref(null);
    const state = reactive({
      x: 0,
      y: 0
    })
    const remove = useEvent(elref, 'mousemove', e=> {
      state.x = e.x;
      state.y = e.y;
    })

    return {
      elref,
      remove,
      state
    }
  }
}
github pikax / vue-composable / docs / .vuepress / components / LocalStorageExample.vue View on Github external
setup() {
    const key = "__vue_localStorage_example";
    const { storage } = useLocalStorage(key, 1);

    return {
      key,
      storage
    };
  }
};
github pikax / vue-composable / docs / .vuepress / components / OnMouseMoveExample.vue View on Github external
setup(_) {
    const elref = ref(null);

    const { mouseX, mouseY, remove } = useOnMouseMove(elref);

    return {
      elref,
      remove,
      mouseX,
      mouseY
    };
  }
};
github pikax / vue-composable / docs / .vuepress / components / OnResizeExample.vue View on Github external
setup(_) {
    const { height, width, remove } = useOnResize(document.body);

    return {
      height,
      width,
      remove
    };
  }
};
github pikax / vue-composable / docs / .vuepress / components / OnScrollExample.vue View on Github external
setup(_) {
    const elref = ref(null);

    const { scrollTop, scrollLeft, remove } = useOnScroll(elref);

    return {
      elref,
      scrollTop,
      scrollLeft,
      remove
    };
  }
};
github pikax / vue-composable / docs / .vuepress / components / WebSocketExample.vue View on Github external
setup() {
    const { isOpen, isClosed, data, errored, send, close } = useWebSocket(
      "wss://javascript.info/article/websocket/demo/hello"
    );

    return {
      isOpen,
      isClosed,
      data,
      errored,
      send,
      close
    };
  }
};