treble-hook
Advanced tools
Comparing version 2.0.11 to 2.0.13
@@ -11,4 +11,4 @@ import React, { Dispatch, SetStateAction } from 'react'; | ||
export declare function useSub<T>(topic: string): T; | ||
export declare function usePub<T>(topic: string): (value: T) => void; | ||
export declare function usePub<T>(topic: string): React.Dispatch<React.SetStateAction<T>>; | ||
export declare type Publish<T> = Dispatch<SetStateAction<T>>; | ||
export declare type PubSubTuple<T> = [T, Publish<T>]; |
@@ -88,3 +88,3 @@ "use strict"; | ||
} | ||
return (value) => { context[1](value); }; | ||
return context[1]; | ||
} | ||
@@ -91,0 +91,0 @@ exports.usePub = usePub; |
{ | ||
"name": "treble-hook", | ||
"version": "2.0.11", | ||
"version": "2.0.13", | ||
"description": "Get hooked on simple subscribe-and-publish in ReactJS.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -206,3 +206,3 @@ | ||
**IMPORTANT**: This hook will still cause re-renders when a new value is published even though the published value isn't used/returned. | ||
**IMPORTANT**: Even though this hook only returns the publish function, it will still cause a re-render whenever a value for respective topic is published outside the scope of this component (i.e. when published from another component). | ||
@@ -209,0 +209,0 @@ ```ts |
Sorry, the diff of this file is not supported yet
17671