@fluent-windows/hooks
Version:
Fluent-Windows React hooks.
26 lines (25 loc) • 587 B
TypeScript
/**
* EventBus hooks
*
* Demo
* import { useAction, useDispatch } from '@fluent-windows/hooks'
*
* // parent
* useAction(
* 'navigation/active',
* (payload) => {
* // ...
* },
* []
* )
*
* // children
* const dispatch = useDispatch({ type: 'navigation/active', payload: 'xxx' })
* function handleClick() {
* dispatch()
* }
* <button onClick={handleClick}>child</button>
*/
import { Type, Callback, Deps, dispatch } from './subscribers';
declare function useAction(type: Type, callback: Callback, deps?: Deps): typeof dispatch;
export default useAction;