@duckness/use-pool
v1.0.0
Published
React hook for @duckness/pool
Downloads
226
Maintainers
Readme
@duckness/use-pool
React hook for @duckness/pool.
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:
- @duckness/duck - Modular Redux Ducks hatchery
- @duckness/saga - Redux Saga extension for @duckness/duck
- @duckness/epic - Redux-Observable extension for @duckness/duck
- @duckness/pool - @duckness/duck + Redux
- @duckness/pool-saga-stream - @duckness/saga plugin for @duckness/pool
- @duckness/pool-epic-stream - @duckness/epic plugin for @duckness/pool
- @duckness/react-redux-pool - @duckness/pool + React-Redux
- @duckness/use-redux - React hook for Redux store
- @duckness/use-pool - React hook for @duckness/pool.
- @duckness/store - simple store for React components
- @duckness/reactor - reactive data flow builder