Nebulous Pumpkin Moons

    @duckness/use-pool

    0.9.0 • Public • Published

    @duckness/use-pool

    React hook for @duckness/pool.

    NPM License Libraries.io dependency status for latest release, scoped npm package GitHub issues vulnerabilities npm bundle size

    Example

    import React from 'react'
    import usePool from '@duckness/use-pool'
    
    import CounterPool from './CounterPool'
    import CounterDuck from './CounterDuck'
    
    export default function Counter() {
      const counter = usePool(CounterPool, CounterDuck.select.counter)
      return <span>[ {counter} ]</span>
    }

    Table of Contents

    Shortcut to @duckness/use-redux

    @duckness/use-pool is a shortcut to @duckness/use-redux.

    See @duckness/use-redux documentation for details.

    import useRedux, {
      useDispatchAction as useReduxDispatchAction,
      useDispatch as useReduxDispatch,
      connect as useReduxConnect,
      combineSelectors
    } from '@duckness/use-redux'
    
    export default function usePool(pool, selector, shouldUpdate, shouldSelect) {
      return useRedux(pool.store, selector, shouldUpdate, shouldSelect)
    }
    
    export function useDispatchAction(pool, actionCreator, payloadTransformer) {
      return useReduxDispatchAction(pool.store, actionCreator, payloadTransformer)
    }
    
    export function useDispatch(pool, dispatcher, deps) {
      return useReduxDispatch(pool.store, dispatcher, deps)
    }
    
    export { combineSelectors }
    
    export function connect(pool, selector, shouldUpdate, shouldSelect, dispatch = pool.dispatch) {
      return useReduxConnect(pool.store, selector, shouldUpdate, shouldSelect, dispatch)
    }

    @Duckness packages:

    Dependencies (1)

    Dev Dependencies (0)

      Install

      npm i @duckness/use-pool

      DownloadsWeekly Downloads

      64

      Version

      0.9.0

      License

      MIT

      Unpacked Size

      10.7 kB

      Total Files

      5

      Last publish

      Collaborators

      • hitosu