vue-hooks-plus

website·Indexed 30 days ago

https://inhiblabcore.github.io/docs/hooks

A collection of Vue hooks for state management and common utility logic. Includes hooks for storage (useLocalStorageState, useCookieState, useSessionStorageState), data fetching (useRequest, useFetchs), state manipulation (useImmer, useMap, useSet, useCounter), and browser APIs (useWorker, useResizeObserver, useTitle, useDarkMode).

Tokens
68.5K
Snippets
406
Records
613
Agent score
70%

What's inside vue-hooks-plus

  1. Overview of useRequest capabilities

    useRequest is a hook designed to manage network requests with a plugin-based architecture. It provides a wide range of built-in capabilities including automatic and manual requests, polling, debouncing, throttling, re-fetching on window focus, error retries, loading delays, SWR (stale-while-revalidate), caching, infinite scrolling/pagination, parallel requests, and support for custom plugins.
  2. Overview of useRequest capabilities

    The useRequest hook provides a comprehensive set of tools for managing network requests in Vue applications. Its core capabilities include:

    • Automatic and manual request triggering
    • Polling, Debouncing, and Throttling
    • Refreshing data on window focus
    • Error retry mechanisms and loading delays
    • SWR (stale-while-revalidate) and Caching
    • Infinite scrolling and Fetchs support
    • Plugin extensibility
  3. Overview of useWorker hook

    useWorker is a Vue Hook that wraps the Web Worker Web API. It allows developers to run computationally expensive functions in a background thread using a simple Promise-based syntax, preventing the main user interface thread from freezing.
  4. Overview of VueHooks Plus

    VueHooks Plus is a collection of basic and advanced Vue 3 hooks designed for high-performance logic abstraction. It is built with TypeScript for full type safety, supports Server-Side Rendering (SSR), and allows for tree-shaking via on-demand loading to reduce bundle size. Key features include a plugin-based request function called useRequest and a comprehensive set of utility hooks for common scenarios.
  5. Overview of VueHooks Plus

    VueHooks Plus is a library of basic and advanced Vue 3 hooks designed for high-performance logic abstraction. It is built with TypeScript for full type safety, supports Server-Side Rendering (SSR), and allows for tree-shaking via on-demand loading to minimize bundle size. Key features include a plugin-based request function called useRequest and a comprehensive set of utility hooks for common scenarios.
  6. Overview of VueHooks Plus

    VueHooks Plus is a comprehensive collection of basic hooks for Vue 3. It is written in TypeScript for predictable static typing, supports Server-Side Rendering (SSR), and supports on-demand loading to keep bundle sizes small. Key features include a powerful request middle tier via useRequest and a focus on safety and reliability through extensive testing.
  7. Overview of useRequest capabilities

    useRequest is a plugin-based hook designed to manage network requests. It provides a wide range of built-in features to handle common API interaction patterns, including:

    • Automatic and manual request triggering
    • Polling, Debouncing, and Throttling
    • Re-fetching on window focus
    • Error retries and loading delays
    • SWR (stale-while-revalidate) and Caching
    • Infinite scrolling and pagination
    • Parallel requests
    • Support for custom plugins
  8. Manage reactive object state with useSetState

    The useSetState hook is used to manage reactive state of object types. It is designed to be more maintainable than standard state management by supporting partial updates (patching) and destructuring.
  9. Manage WebSocket connections with useWebSocket

    The useWebSocket hook provides a simplified interface for creating and managing a WebSocket connection. It handles connection lifecycle events, automatic reconnection logic, and provides a reactive state of the connection status.
    const { readyState, sendMessage, disconnect, connect } = useWebSocket('wss://example.com/socket', {
      onMessage: (event) => console.log('Received:', event.data),
      reconnectLimit: 5,
    });
  10. Monitor network connection state with useNetwork

    The useNetwork hook provides real-time information about the device's network connectivity, including online status, connection type, and estimated bandwidth. It returns a NetworkState object containing the following properties:

    • online: Boolean indicating if the device is currently online.
    • since: The Date when the online status last changed.
    • rtt: Estimated round-trip time of the current connection (number).
    • type: The type of connection (e.g., 'bluetooth', 'cellular', 'ethernet', 'none', 'wifi', 'wimax', 'other', 'unknown').
    • downlink: Estimated effective bandwidth in megabits per second (Mbps).
    • downlinkMax: Maximum downlink speed in megabits per second (Mbps).
    • saveData: Boolean indicating if the user agent has enabled a data-saver mode.
    • effectiveType: The effective connection type (e.g., 'slow-2g', '2g', '3g', '4g').
    interface NetworkState {
      online?: boolean
      since?: Date
      rtt?: number
      type?: string
      downlink?: number
      saveData?: boolean
      downlinkMax?: number
      effectiveType?: string
    }
    
    const result: NetworkState = useNetwork()
  11. Manage parallel requests with useFetchs

    The useFetchs hook is built upon useRequest to enable powerful parallel request capabilities. It is specifically designed to elegantly manage multiple requests to the same URL that carry different parameters. To use fetchRun for manual execution, the manual option must be set to true in the useRequest configuration.