From 0d7703584d6cd6a498c135fe00acb5ea43928654 Mon Sep 17 00:00:00 2001 From: Harley Alexander Date: Tue, 18 Feb 2020 11:44:02 +1100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8F=B7=E2=99=BB=EF=B8=8F=20improved?= =?UTF-8?q?=20types,=20refactored=20hooks=20for=20simplicity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .netlify/state.json | 3 ++ src/PusherProvider.tsx | 49 ++++++++++---------- src/helpers.ts | 17 ------- src/types.ts | 15 ++---- src/useChannel.ts | 20 +++++--- src/useClientTrigger.ts | 17 ++++++- src/useEvent.ts | 4 +- src/usePresenceChannel.ts | 97 ++++++++++++++++----------------------- src/usePusher.ts | 7 ++- src/useTrigger.ts | 50 ++++++++++---------- 10 files changed, 133 insertions(+), 146 deletions(-) create mode 100644 .netlify/state.json delete mode 100644 src/helpers.ts diff --git a/.netlify/state.json b/.netlify/state.json new file mode 100644 index 0000000..6fc2d21 --- /dev/null +++ b/.netlify/state.json @@ -0,0 +1,3 @@ +{ + "siteId": "aa919ed6-b843-411b-b6f7-828ea279b040" +} \ No newline at end of file diff --git a/src/PusherProvider.tsx b/src/PusherProvider.tsx index b3d8cc9..8cb0c65 100644 --- a/src/PusherProvider.tsx +++ b/src/PusherProvider.tsx @@ -10,49 +10,52 @@ const PusherContext = React.createContext({}); export const __PusherContext = PusherContext; /** - * Provider for the pusher service in an app + * Provider that creates your pusher instance and provides it to child hooks throughout your app. + * Note, you can pass in value={{}} as a prop if you'd like to override the pusher client passed. + * This is handy when simulating pusher locally, or for testing. * @param props Config for Pusher client */ -export function PusherProvider({ + +export const PusherProvider: React.FC = ({ clientKey, cluster, triggerEndpoint, - authEndpoint, - auth, defer = false, + children, ...props -}: PusherProviderProps) { +}) => { // errors when required props are not passed. invariant(clientKey, 'A client key is required for pusher'); invariant(cluster, 'A cluster is required for pusher'); - const { children, ...additionalConfig } = props; - const config: Options = { cluster, ...additionalConfig }; - if (authEndpoint) config.authEndpoint = authEndpoint; - if (auth) config.auth = auth; - const pusherClientRef = useRef(); + const config: Options = { cluster, ...props }; + + const pusherClientRef = useRef(); // track config for comparison - const previousConfig = useRef(); + const previousConfig = useRef(props); useEffect(() => { - previousConfig.current = config; + previousConfig.current = props; }); useEffect(() => { - // if client exists and options are the same, skip. - if (dequal(previousConfig.current, config) && pusherClientRef.current !== undefined) { + // Skip creation of client if deferring, a value prop is passed, or config props are the same. + if ( + defer || + props.value || + (dequal(previousConfig.current, props) && pusherClientRef.current !== undefined) + ) { return; } - // optional defer parameter skips creating the class. - // handy if you want to wait for something async like - // a JWT before creating it. - if (!defer) { - pusherClientRef.current = new Pusher(clientKey, config); - } + // create the client and assign it to the ref + pusherClientRef.current = new Pusher(clientKey, config); - return () => pusherClientRef.current && pusherClientRef.current.disconnect(); - }, [clientKey, config, defer, pusherClientRef]); + // cleanup + return () => { + pusherClientRef.current && pusherClientRef.current.disconnect(); + }; + }, [clientKey, props, defer, pusherClientRef]); return ( ); -} +}; diff --git a/src/helpers.ts b/src/helpers.ts deleted file mode 100644 index 479a61c..0000000 --- a/src/helpers.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { useRef } from "react"; -import deepEqual from "dequal"; - -/** - * Nice helper to deep compare memoize - * @copyright Kent C. Dodds - * @param value value to memoize - */ -export function useDeepCompareMemoize(value: any[]) { - const ref = useRef(); - - if (!deepEqual(value, ref.current)) { - ref.current = value; - } - - return ref.current; -} diff --git a/src/types.ts b/src/types.ts index 640209a..c9fe7f6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,23 +1,16 @@ -import { Options, AuthOptions } from 'pusher-js'; +import Pusher, { Options } from 'pusher-js'; import * as React from 'react'; export interface PusherContextValues { - client?: any | undefined; + client?: React.MutableRefObject; triggerEndpoint?: string; } export interface PusherProviderProps extends Options { clientKey: string; - cluster: string; - authEndpoint?: string; - auth?: AuthOptions; + cluster: 'mt1' | 'us2' | 'us3' | 'eu' | 'ap1' | 'ap2' | 'ap3' | 'ap4'; triggerEndpoint?: string; defer?: boolean; - children: React.ReactNode; // for testing purposes - value?: any; -} - -export interface useChannelOptions { - skip?: boolean; + value?: PusherContextValues; } diff --git a/src/useChannel.ts b/src/useChannel.ts index d2d09ab..6b092f5 100644 --- a/src/useChannel.ts +++ b/src/useChannel.ts @@ -1,28 +1,36 @@ import { useEffect, useState } from 'react'; import invariant from 'invariant'; +import { Channel, PresenceChannel } from 'pusher-js'; import { usePusher } from './usePusher'; /** - * Subscribe to channel + * Subscribe to a channel + * + * @param channelName The name of the channel you want to subscribe to. + * @typeparam Type of channel you're subscribing to. Can be one of Channel or PresenceChannel. + * @returns Instance of the channel you just subscribed to. * * @example - * useChannel("my-channel") + * ```javascript + * const channel = useChannel("my-channel") + * channel.bind('some-event', () => {}) + * ``` */ -export function useChannel(channelName: string) { +export function useChannel(channelName: string) { // errors for missing arguments invariant(channelName, 'channelName required to subscribe to a channel'); const { client } = usePusher(); const pusherClient = client && client.current; - const [channel, setChannel] = useState(); + const [channel, setChannel] = useState(); useEffect(() => { if (!pusherClient) return; - const channel = pusherClient.subscribe(channelName); - setChannel(channel); + const pusherChannel = pusherClient.subscribe(channelName); + setChannel(pusherChannel as T); }, [channelName, pusherClient]); return channel; } diff --git a/src/useClientTrigger.ts b/src/useClientTrigger.ts index 0bc02ea..e4a0ed2 100644 --- a/src/useClientTrigger.ts +++ b/src/useClientTrigger.ts @@ -2,7 +2,20 @@ import { useCallback } from 'react'; import invariant from 'invariant'; import { Channel, PresenceChannel } from 'pusher-js'; -export function useClientTrigger(channel: Channel | PresenceChannel) { +/** + * + * @param channel the channel you'd like to trigger clientEvents on. Get this from [[useChannel]] or [[usePresenceChannel]]. + * @typeparam TData shape of the data you're sending with the event. + * @returns A memoized trigger function that will perform client events on the channel. + * @example + * ```javascript + * const channel = useChannel('my-channel'); + * const trigger = useClientTrigger(channel) + * + * const handleClick = () => trigger('some-client-event', {}); + * ``` + */ +export function useClientTrigger(channel: Channel | PresenceChannel) { channel && invariant( channel.name.match(/(private-|presence-)/gi), @@ -11,7 +24,7 @@ export function useClientTrigger(channel: Channel | PresenceChannel) { // memoize trigger so it's not being created every render const trigger = useCallback( - (eventName: string, data: any = {}) => { + (eventName: string, data: TData) => { invariant(eventName, 'Must pass event name to trigger a client event.'); channel && channel.trigger(eventName, data); }, diff --git a/src/useEvent.ts b/src/useEvent.ts index 58e559e..5e1f78e 100644 --- a/src/useEvent.ts +++ b/src/useEvent.ts @@ -7,7 +7,6 @@ import { Channel, PresenceChannel } from 'pusher-js'; * @param channel Pusher channel to bind to * @param eventName Name of event to bind to * @param callback Callback to call on a new event - * @param dependencies Dependencies the callback uses. */ export function useEvent( channel: Channel | PresenceChannel | undefined, @@ -32,8 +31,7 @@ export function useEvent( useEffect(() => { if (channel === undefined) { return; - } - channel.bind(eventName, callback); + } else channel.bind(eventName, callback); return () => { channel.unbind(eventName, callback); }; diff --git a/src/usePresenceChannel.ts b/src/usePresenceChannel.ts index 660ec06..adf2bba 100644 --- a/src/usePresenceChannel.ts +++ b/src/usePresenceChannel.ts @@ -1,6 +1,6 @@ -import { useCallback, useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; -import { PresenceChannel } from 'pusher-js'; +import { PresenceChannel, Members } from 'pusher-js'; import invariant from 'invariant'; import { useChannel } from './useChannel'; @@ -8,22 +8,16 @@ import { useChannel } from './useChannel'; /** * Subscribe to presence channel events and get members back * - * @param channelName name of presence channel. Should have presence- suffix. - * @param eventName name of event to bind to - * @param onEvent callback to fire when event is called - * @param dependencies dependencies array that onEvent uses - * @param options optional argument to skip events + * @param channelName name of presence the channel. Should have `presence-` suffix. + * @returns Object with `channel`, `members` and `myID` properties. * * @example - * const {members} = usePresenceChannel( - * "my-channel", - * "my-event", - * (message) => console.log(message), - * ) + * ```javascript + * const { channel, members, myID } = usePresenceChannel("presence-my-channel"); + * ``` */ export function usePresenceChannel(channelName: string) { // errors for missing arguments - invariant(channelName, 'channelName required to subscribe to a channel'); invariant( channelName.includes('presence-'), "Presence channels should use prefix 'presence-' in their name. Use the useChannel hook instead." @@ -32,44 +26,34 @@ export function usePresenceChannel(channelName: string) { // Get regular channel functionality const [members, setMembers] = useState({}); const [myID, setMyID] = useState(); - /** - * Get members info on subscription success - */ - const handleSubscriptionSuccess = useCallback((members: any) => { - setMembers(members.members); - setMyID(members.myID); - }, []); - /** - * Add or update member in object. - * @note not using a new Map() here to match pusher-js library. - * @param member member being added - */ - const handleAdd = useCallback((member: any) => { - setMembers(previousMembers => ({ - ...previousMembers, - [member.id]: member.info, - })); - }, []); - - /** - * Remove member from the state object. - * @param member Member being removed - */ - const handleRemove = useCallback((member: any) => { - setMembers(previousMembers => { - const nextMembers: any = { ...previousMembers }; - delete nextMembers[member.id]; - return nextMembers; - }); - }, []); - - /** - * Bind and unbind to membership events - */ - const channel = useChannel(channelName); + // bind and unbind member events events on our channel + const channel = useChannel(channelName); useEffect(() => { if (channel) { + // Get membership info on successful subscription + const handleSubscriptionSuccess = (members: Members) => { + setMembers(members.members); + setMyID(members.myID); + }; + + // add a member to the members object + const handleAdd = (member: any) => { + setMembers(previousMembers => ({ + ...previousMembers, + [member.id]: member.info, + })); + }; + + // remove a member from the members object + const handleRemove = (member: any) => { + setMembers(previousMembers => { + const nextMembers: any = { ...previousMembers }; + delete nextMembers[member.id]; + return nextMembers; + }); + }; + // bind to all member addition/removal events channel.bind('pusher:subscription_succeeded', handleSubscriptionSuccess); channel.bind('pusher:member_added', handleAdd); @@ -80,22 +64,21 @@ export function usePresenceChannel(channelName: string) { setMembers(channel.members.members); setMyID(channel.members.myID); } - } - // cleanup - return () => { - if (channel) { + // cleanup + return () => { channel.unbind('pusher:subscription_succeeded', handleSubscriptionSuccess); channel.unbind('pusher:member_added', handleAdd); channel.unbind('pusher:member_removed', handleRemove); - } - }; - }, [channel, handleSubscriptionSuccess, handleAdd, handleRemove]); + }; + } - const presenceChannel = channel as PresenceChannel; + // to make typescript happy. + return () => {}; + }, [channel]); return { - channel: presenceChannel, + channel, members, myID, }; diff --git a/src/usePusher.ts b/src/usePusher.ts index 43175a5..6d211d4 100644 --- a/src/usePusher.ts +++ b/src/usePusher.ts @@ -3,11 +3,14 @@ import { __PusherContext } from './PusherProvider'; import { PusherContextValues } from './types'; /** - * Provides access to the pusher client + * Provides access to the pusher client instance. * + * @returns a `MutableRefObject`. The instance is held by a `useRef()` hook. * @example - * const {client} = usePusher(); + * ```javscript + * const { client } = usePusher(); * client.current.subscribe('my-channel'); + * ``` */ export function usePusher() { const context = useContext(__PusherContext); diff --git a/src/useTrigger.ts b/src/useTrigger.ts index 8d2d65c..515ce05 100644 --- a/src/useTrigger.ts +++ b/src/useTrigger.ts @@ -1,50 +1,50 @@ -import { useCallback } from "react"; -import { usePusher } from "./usePusher"; -import invariant from "invariant"; -import { useChannel } from "./useChannel"; +import { useCallback } from 'react'; +import { usePusher } from './usePusher'; +import invariant from 'invariant'; +import { useChannel } from './useChannel'; /** - * Trigger events hook + * Hook to provide a trigger function that calls the server defined in `PusherProviderProps.triggerEndpoint` using `fetch`. + * Any `auth?.headers` in the config object will be passed with the `fetch` call. * - * @example + * @param channelName name of channel to call trigger on + * @typeparam TData shape of the data you're sending with the event * - * const trigger = useTrigger('my-channel'); + * @example + * ```typescript + * const trigger = useTrigger<{message: string}>('my-channel'); * trigger('my-event', {message: 'hello'}); + * ``` */ -export function useTrigger(channelName: string) { +export function useTrigger(channelName: string) { const { client, triggerEndpoint } = usePusher(); - // subscribe to the channel we'll be triggering to. - useChannel(channelName); - - invariant(channelName, "No channel specified to trigger to."); - + // you can't use this if you haven't supplied a triggerEndpoint. invariant( triggerEndpoint, - "No trigger endpoint specified to . Cannot trigger an event." + 'No trigger endpoint specified to . Cannot trigger an event.' ); - /** - * Memoized trigger function - */ + // subscribe to the channel we'll be triggering to. + useChannel(channelName); + + // memoized trigger function to return const trigger = useCallback( - (eventName: string, data?: any) => { + (eventName: string, data?: TData) => { const fetchOptions: RequestInit = { - method: "POST", - body: JSON.stringify({ channelName, eventName, data }) + method: 'POST', + body: JSON.stringify({ channelName, eventName, data }), }; - if (client.current && client.current.config.auth) { + if (client && client.current && client.current.config.auth) { fetchOptions.headers = client.current.config.auth.headers; } else { console.warn( - "No auth parameters supplied to . Your events will be unauthenticated." + 'No auth parameters supplied to . Your events will be unauthenticated.' ); } - // forcing triggerEndpoint to exist for TS here - // because invariant will throw during dev - return fetch(triggerEndpoint!, fetchOptions); + return fetch(triggerEndpoint, fetchOptions); }, [client, triggerEndpoint, channelName] ); From bb1fbb2e173ced44c8af4917250a7d436e0c6123 Mon Sep 17 00:00:00 2001 From: Harley Alexander Date: Tue, 18 Feb 2020 12:09:26 +1100 Subject: [PATCH 2/3] v3.2.0 --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 56d7269..47578b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@harelpls/use-pusher", - "version": "3.1.2", + "version": "3.2.0", "description": "A wrapper around pusher-js for easy-as hooks in React.", "author": "@mayteio", "keywords": [ @@ -21,7 +21,7 @@ "main": "dist/index.js", "module": "dist/index.es.js", "jsnext:main": "dist/index.es.js", - "typings": "dist/index.d.ts", + "types": "dist/index.d.ts", "engines": { "node": ">=8", "npm": ">=5" @@ -29,11 +29,11 @@ "scripts": { "test": "cross-env CI=1 react-scripts test --env=jsdom", "test:watch": "react-scripts test --env=jsdom", - "build": "rollup -c", + "build": "rimraf dist && rollup -c", "start": "rollup -c -w", "types": "dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --external-imports pusher-js", "docs": "typedoc --options ./typedoc.js ./src", - "release": "yarn test && yarn build && yarn types && yarn publish" + "release": "yarn test && yarn build && yarn types && yarn publish && ntl deploy" }, "dependencies": { "dequal": "^1.0.0", @@ -64,6 +64,7 @@ "react-dom": "^16.9.0", "react-scripts": "^3.0.1", "react-test-renderer": "^16.9.0", + "rimraf": "^3.0.2", "rollup": "^1.20.0", "rollup-plugin-babel": "^4.3.3", "rollup-plugin-commonjs": "^10.0.2", From 688e15561335eb8f5bad5bcfe8bc59ac8d81389a Mon Sep 17 00:00:00 2001 From: Harley Alexander Date: Tue, 18 Feb 2020 12:14:46 +1100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A7=B9=20cleanup=20docs=20and=20deplo?= =?UTF-8?q?y=20to=20netlify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/assets/js/search.js | 2 +- docs/classes/_mocks_.pusherchannelmock.html | 27 +- docs/classes/_mocks_.pushermock.html | 19 +- .../_mocks_.pusherpresencechannelmock.html | 31 +-- .../_types_.pushercontextvalues.html | 9 +- .../_types_.pusherproviderprops.html | 51 ++-- .../interfaces/_types_.usechanneloptions.html | 234 ------------------ docs/modules/_mocks_.html | 46 ++++ docs/modules/_pusherprovider_.html | 26 +- docs/modules/_types_.html | 4 - docs/modules/_usechannel_.html | 32 ++- docs/modules/_useclienttrigger_.html | 35 ++- docs/modules/_useevent_.html | 5 +- docs/modules/_usepresencechannel_.html | 17 +- docs/modules/_usepusher_.html | 11 +- docs/modules/_usetrigger_.html | 31 ++- rollup.config.js | 2 + src/index.ts | 16 +- src/mocks.ts | 8 +- src/useChannel.ts | 2 +- src/usePusher.ts | 2 +- yarn.lock | 7 + 22 files changed, 233 insertions(+), 384 deletions(-) delete mode 100644 docs/interfaces/_types_.usechanneloptions.html diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 10307e5..579619d 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"1":"External module","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal"},"rows":[{"id":0,"kind":1,"name":"\"types\"","url":"modules/_types_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"PusherContextValues","url":"interfaces/_types_.pushercontextvalues.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"types\""},{"id":2,"kind":1024,"name":"client","url":"interfaces/_types_.pushercontextvalues.html#client","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherContextValues"},{"id":3,"kind":1024,"name":"triggerEndpoint","url":"interfaces/_types_.pushercontextvalues.html#triggerendpoint","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherContextValues"},{"id":4,"kind":256,"name":"PusherProviderProps","url":"interfaces/_types_.pusherproviderprops.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"types\""},{"id":5,"kind":1024,"name":"clientKey","url":"interfaces/_types_.pusherproviderprops.html#clientkey","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":6,"kind":1024,"name":"cluster","url":"interfaces/_types_.pusherproviderprops.html#cluster","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite","parent":"\"types\".PusherProviderProps"},{"id":7,"kind":1024,"name":"authEndpoint","url":"interfaces/_types_.pusherproviderprops.html#authendpoint","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite","parent":"\"types\".PusherProviderProps"},{"id":8,"kind":1024,"name":"auth","url":"interfaces/_types_.pusherproviderprops.html#auth","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite","parent":"\"types\".PusherProviderProps"},{"id":9,"kind":1024,"name":"triggerEndpoint","url":"interfaces/_types_.pusherproviderprops.html#triggerendpoint","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":10,"kind":1024,"name":"defer","url":"interfaces/_types_.pusherproviderprops.html#defer","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":11,"kind":1024,"name":"children","url":"interfaces/_types_.pusherproviderprops.html#children","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":12,"kind":1024,"name":"value","url":"interfaces/_types_.pusherproviderprops.html#value","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":13,"kind":1024,"name":"activityTimeout","url":"interfaces/_types_.pusherproviderprops.html#activitytimeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":14,"kind":1024,"name":"enableStats","url":"interfaces/_types_.pusherproviderprops.html#enablestats","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":15,"kind":1024,"name":"disableStats","url":"interfaces/_types_.pusherproviderprops.html#disablestats","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":16,"kind":1024,"name":"authTransport","url":"interfaces/_types_.pusherproviderprops.html#authtransport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":17,"kind":1024,"name":"authorizer","url":"interfaces/_types_.pusherproviderprops.html#authorizer","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":18,"kind":1024,"name":"disabledTransports","url":"interfaces/_types_.pusherproviderprops.html#disabledtransports","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":19,"kind":1024,"name":"enabledTransports","url":"interfaces/_types_.pusherproviderprops.html#enabledtransports","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":20,"kind":1024,"name":"encrypted","url":"interfaces/_types_.pusherproviderprops.html#encrypted","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":21,"kind":1024,"name":"forceTLS","url":"interfaces/_types_.pusherproviderprops.html#forcetls","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":22,"kind":1024,"name":"ignoreNullOrigin","url":"interfaces/_types_.pusherproviderprops.html#ignorenullorigin","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":23,"kind":1024,"name":"pongTimeout","url":"interfaces/_types_.pusherproviderprops.html#pongtimeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":24,"kind":1024,"name":"statsHost","url":"interfaces/_types_.pusherproviderprops.html#statshost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":25,"kind":1024,"name":"timelineParams","url":"interfaces/_types_.pusherproviderprops.html#timelineparams","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":26,"kind":1024,"name":"unavailable_timeout","url":"interfaces/_types_.pusherproviderprops.html#unavailable_timeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":27,"kind":1024,"name":"wsHost","url":"interfaces/_types_.pusherproviderprops.html#wshost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":28,"kind":1024,"name":"httpHost","url":"interfaces/_types_.pusherproviderprops.html#httphost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":29,"kind":1024,"name":"wsPath","url":"interfaces/_types_.pusherproviderprops.html#wspath","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":30,"kind":1024,"name":"wsPort","url":"interfaces/_types_.pusherproviderprops.html#wsport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":31,"kind":1024,"name":"wssPort","url":"interfaces/_types_.pusherproviderprops.html#wssport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":32,"kind":1024,"name":"httpPort","url":"interfaces/_types_.pusherproviderprops.html#httpport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":33,"kind":1024,"name":"httpsPort","url":"interfaces/_types_.pusherproviderprops.html#httpsport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":34,"kind":256,"name":"useChannelOptions","url":"interfaces/_types_.usechanneloptions.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"types\""},{"id":35,"kind":1024,"name":"skip","url":"interfaces/_types_.usechanneloptions.html#skip","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".useChannelOptions"},{"id":36,"kind":1,"name":"\"PusherProvider\"","url":"modules/_pusherprovider_.html","classes":"tsd-kind-external-module"},{"id":37,"kind":32,"name":"PusherContext","url":"modules/_pusherprovider_.html#pushercontext","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"PusherProvider\""},{"id":38,"kind":32,"name":"__PusherContext","url":"modules/_pusherprovider_.html#__pushercontext","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"PusherProvider\""},{"id":39,"kind":64,"name":"PusherProvider","url":"modules/_pusherprovider_.html#pusherprovider","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"PusherProvider\""},{"id":40,"kind":1,"name":"\"mocks\"","url":"modules/_mocks_.html","classes":"tsd-kind-external-module"},{"id":41,"kind":128,"name":"PusherChannelMock","url":"classes/_mocks_.pusherchannelmock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":42,"kind":1024,"name":"callbacks","url":"classes/_mocks_.pusherchannelmock.html#callbacks","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":43,"kind":65536,"name":"__type","url":"classes/_mocks_.pusherchannelmock.html#callbacks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherChannelMock.callbacks"},{"id":44,"kind":1024,"name":"name","url":"classes/_mocks_.pusherchannelmock.html#name","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":45,"kind":512,"name":"constructor","url":"classes/_mocks_.pusherchannelmock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":46,"kind":2048,"name":"bind","url":"classes/_mocks_.pusherchannelmock.html#bind","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":47,"kind":2048,"name":"unbind","url":"classes/_mocks_.pusherchannelmock.html#unbind","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":48,"kind":2048,"name":"emit","url":"classes/_mocks_.pusherchannelmock.html#emit","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":49,"kind":2048,"name":"trigger","url":"classes/_mocks_.pusherchannelmock.html#trigger","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":50,"kind":128,"name":"PusherPresenceChannelMock","url":"classes/_mocks_.pusherpresencechannelmock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":51,"kind":1024,"name":"members","url":"classes/_mocks_.pusherpresencechannelmock.html#members","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":52,"kind":1024,"name":"myID","url":"classes/_mocks_.pusherpresencechannelmock.html#myid","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":53,"kind":512,"name":"constructor","url":"classes/_mocks_.pusherpresencechannelmock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":54,"kind":1024,"name":"callbacks","url":"classes/_mocks_.pusherpresencechannelmock.html#callbacks","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":55,"kind":65536,"name":"__type","url":"classes/_mocks_.pusherpresencechannelmock.html#callbacks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherPresenceChannelMock.callbacks"},{"id":56,"kind":1024,"name":"name","url":"classes/_mocks_.pusherpresencechannelmock.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":57,"kind":2048,"name":"bind","url":"classes/_mocks_.pusherpresencechannelmock.html#bind","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":58,"kind":2048,"name":"unbind","url":"classes/_mocks_.pusherpresencechannelmock.html#unbind","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":59,"kind":2048,"name":"emit","url":"classes/_mocks_.pusherpresencechannelmock.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":60,"kind":2048,"name":"trigger","url":"classes/_mocks_.pusherpresencechannelmock.html#trigger","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":61,"kind":128,"name":"PusherMock","url":"classes/_mocks_.pushermock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":62,"kind":1024,"name":"key","url":"classes/_mocks_.pushermock.html#key","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":63,"kind":1024,"name":"config","url":"classes/_mocks_.pushermock.html#config","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":64,"kind":1024,"name":"channels","url":"classes/_mocks_.pushermock.html#channels","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":65,"kind":65536,"name":"__type","url":"classes/_mocks_.pushermock.html#channels.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherMock.channels"},{"id":66,"kind":512,"name":"constructor","url":"classes/_mocks_.pushermock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":67,"kind":2048,"name":"channel","url":"classes/_mocks_.pushermock.html#channel","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":68,"kind":2048,"name":"subscribe","url":"classes/_mocks_.pushermock.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":69,"kind":2048,"name":"unsubscribe","url":"classes/_mocks_.pushermock.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":70,"kind":2048,"name":"disconnect","url":"classes/_mocks_.pushermock.html#disconnect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":71,"kind":1,"name":"\"usePusher\"","url":"modules/_usepusher_.html","classes":"tsd-kind-external-module"},{"id":72,"kind":64,"name":"usePusher","url":"modules/_usepusher_.html#usepusher","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"usePusher\""},{"id":73,"kind":32,"name":"NOT_IN_CONTEXT_WARNING","url":"modules/_usepusher_.html#not_in_context_warning","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"usePusher\""},{"id":74,"kind":1,"name":"\"useChannel\"","url":"modules/_usechannel_.html","classes":"tsd-kind-external-module"},{"id":75,"kind":64,"name":"useChannel","url":"modules/_usechannel_.html#usechannel","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"useChannel\""},{"id":76,"kind":1,"name":"\"useClientTrigger\"","url":"modules/_useclienttrigger_.html","classes":"tsd-kind-external-module"},{"id":77,"kind":64,"name":"useClientTrigger","url":"modules/_useclienttrigger_.html#useclienttrigger","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"useClientTrigger\""},{"id":78,"kind":1,"name":"\"useEvent\"","url":"modules/_useevent_.html","classes":"tsd-kind-external-module"},{"id":79,"kind":64,"name":"useEvent","url":"modules/_useevent_.html#useevent","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"useEvent\""},{"id":80,"kind":1,"name":"\"usePresenceChannel\"","url":"modules/_usepresencechannel_.html","classes":"tsd-kind-external-module"},{"id":81,"kind":64,"name":"usePresenceChannel","url":"modules/_usepresencechannel_.html#usepresencechannel","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"usePresenceChannel\""},{"id":82,"kind":1,"name":"\"useTrigger\"","url":"modules/_usetrigger_.html","classes":"tsd-kind-external-module"},{"id":83,"kind":64,"name":"useTrigger","url":"modules/_usetrigger_.html#usetrigger","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"useTrigger\""}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"1":"External module","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":1,"name":"\"types\"","url":"modules/_types_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"PusherContextValues","url":"interfaces/_types_.pushercontextvalues.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"types\""},{"id":2,"kind":1024,"name":"client","url":"interfaces/_types_.pushercontextvalues.html#client","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherContextValues"},{"id":3,"kind":1024,"name":"triggerEndpoint","url":"interfaces/_types_.pushercontextvalues.html#triggerendpoint","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherContextValues"},{"id":4,"kind":256,"name":"PusherProviderProps","url":"interfaces/_types_.pusherproviderprops.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"types\""},{"id":5,"kind":1024,"name":"clientKey","url":"interfaces/_types_.pusherproviderprops.html#clientkey","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":6,"kind":1024,"name":"cluster","url":"interfaces/_types_.pusherproviderprops.html#cluster","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite","parent":"\"types\".PusherProviderProps"},{"id":7,"kind":1024,"name":"triggerEndpoint","url":"interfaces/_types_.pusherproviderprops.html#triggerendpoint","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":8,"kind":1024,"name":"defer","url":"interfaces/_types_.pusherproviderprops.html#defer","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":9,"kind":1024,"name":"value","url":"interfaces/_types_.pusherproviderprops.html#value","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"\"types\".PusherProviderProps"},{"id":10,"kind":1024,"name":"activityTimeout","url":"interfaces/_types_.pusherproviderprops.html#activitytimeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":11,"kind":1024,"name":"enableStats","url":"interfaces/_types_.pusherproviderprops.html#enablestats","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":12,"kind":1024,"name":"disableStats","url":"interfaces/_types_.pusherproviderprops.html#disablestats","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":13,"kind":1024,"name":"authEndpoint","url":"interfaces/_types_.pusherproviderprops.html#authendpoint","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":14,"kind":1024,"name":"auth","url":"interfaces/_types_.pusherproviderprops.html#auth","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":15,"kind":1024,"name":"authTransport","url":"interfaces/_types_.pusherproviderprops.html#authtransport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":16,"kind":1024,"name":"authorizer","url":"interfaces/_types_.pusherproviderprops.html#authorizer","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":17,"kind":1024,"name":"disabledTransports","url":"interfaces/_types_.pusherproviderprops.html#disabledtransports","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":18,"kind":1024,"name":"enabledTransports","url":"interfaces/_types_.pusherproviderprops.html#enabledtransports","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":19,"kind":1024,"name":"encrypted","url":"interfaces/_types_.pusherproviderprops.html#encrypted","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":20,"kind":1024,"name":"forceTLS","url":"interfaces/_types_.pusherproviderprops.html#forcetls","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":21,"kind":1024,"name":"ignoreNullOrigin","url":"interfaces/_types_.pusherproviderprops.html#ignorenullorigin","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":22,"kind":1024,"name":"pongTimeout","url":"interfaces/_types_.pusherproviderprops.html#pongtimeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":23,"kind":1024,"name":"statsHost","url":"interfaces/_types_.pusherproviderprops.html#statshost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":24,"kind":1024,"name":"timelineParams","url":"interfaces/_types_.pusherproviderprops.html#timelineparams","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":25,"kind":1024,"name":"unavailable_timeout","url":"interfaces/_types_.pusherproviderprops.html#unavailable_timeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":26,"kind":1024,"name":"wsHost","url":"interfaces/_types_.pusherproviderprops.html#wshost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":27,"kind":1024,"name":"httpHost","url":"interfaces/_types_.pusherproviderprops.html#httphost","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":28,"kind":1024,"name":"wsPath","url":"interfaces/_types_.pusherproviderprops.html#wspath","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":29,"kind":1024,"name":"wsPort","url":"interfaces/_types_.pusherproviderprops.html#wsport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":30,"kind":1024,"name":"wssPort","url":"interfaces/_types_.pusherproviderprops.html#wssport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":31,"kind":1024,"name":"httpPort","url":"interfaces/_types_.pusherproviderprops.html#httpport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":32,"kind":1024,"name":"httpsPort","url":"interfaces/_types_.pusherproviderprops.html#httpsport","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"\"types\".PusherProviderProps"},{"id":33,"kind":1,"name":"\"PusherProvider\"","url":"modules/_pusherprovider_.html","classes":"tsd-kind-external-module"},{"id":34,"kind":32,"name":"PusherContext","url":"modules/_pusherprovider_.html#pushercontext","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"PusherProvider\""},{"id":35,"kind":32,"name":"__PusherContext","url":"modules/_pusherprovider_.html#__pushercontext","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"PusherProvider\""},{"id":36,"kind":64,"name":"PusherProvider","url":"modules/_pusherprovider_.html#pusherprovider","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"PusherProvider\""},{"id":37,"kind":1,"name":"\"mocks\"","url":"modules/_mocks_.html","classes":"tsd-kind-external-module"},{"id":38,"kind":128,"name":"PusherChannelMock","url":"classes/_mocks_.pusherchannelmock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":39,"kind":1024,"name":"callbacks","url":"classes/_mocks_.pusherchannelmock.html#callbacks","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":40,"kind":65536,"name":"__type","url":"classes/_mocks_.pusherchannelmock.html#callbacks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherChannelMock.callbacks"},{"id":41,"kind":1024,"name":"name","url":"classes/_mocks_.pusherchannelmock.html#name","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":42,"kind":512,"name":"constructor","url":"classes/_mocks_.pusherchannelmock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":43,"kind":2048,"name":"bind","url":"classes/_mocks_.pusherchannelmock.html#bind","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":44,"kind":2048,"name":"unbind","url":"classes/_mocks_.pusherchannelmock.html#unbind","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":45,"kind":2048,"name":"emit","url":"classes/_mocks_.pusherchannelmock.html#emit","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":46,"kind":2048,"name":"trigger","url":"classes/_mocks_.pusherchannelmock.html#trigger","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherChannelMock"},{"id":47,"kind":128,"name":"PusherPresenceChannelMock","url":"classes/_mocks_.pusherpresencechannelmock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":48,"kind":1024,"name":"members","url":"classes/_mocks_.pusherpresencechannelmock.html#members","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":49,"kind":1024,"name":"myID","url":"classes/_mocks_.pusherpresencechannelmock.html#myid","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":50,"kind":512,"name":"constructor","url":"classes/_mocks_.pusherpresencechannelmock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":51,"kind":1024,"name":"callbacks","url":"classes/_mocks_.pusherpresencechannelmock.html#callbacks","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":52,"kind":65536,"name":"__type","url":"classes/_mocks_.pusherpresencechannelmock.html#callbacks.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherPresenceChannelMock.callbacks"},{"id":53,"kind":1024,"name":"name","url":"classes/_mocks_.pusherpresencechannelmock.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":54,"kind":2048,"name":"bind","url":"classes/_mocks_.pusherpresencechannelmock.html#bind","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":55,"kind":2048,"name":"unbind","url":"classes/_mocks_.pusherpresencechannelmock.html#unbind","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":56,"kind":2048,"name":"emit","url":"classes/_mocks_.pusherpresencechannelmock.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":57,"kind":2048,"name":"trigger","url":"classes/_mocks_.pusherpresencechannelmock.html#trigger","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"\"mocks\".PusherPresenceChannelMock"},{"id":58,"kind":128,"name":"PusherMock","url":"classes/_mocks_.pushermock.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"mocks\""},{"id":59,"kind":1024,"name":"key","url":"classes/_mocks_.pushermock.html#key","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":60,"kind":1024,"name":"config","url":"classes/_mocks_.pushermock.html#config","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":61,"kind":1024,"name":"channels","url":"classes/_mocks_.pushermock.html#channels","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":62,"kind":65536,"name":"__type","url":"classes/_mocks_.pushermock.html#channels.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property","parent":"\"mocks\".PusherMock.channels"},{"id":63,"kind":512,"name":"constructor","url":"classes/_mocks_.pushermock.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":64,"kind":2048,"name":"channel","url":"classes/_mocks_.pushermock.html#channel","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":65,"kind":2048,"name":"subscribe","url":"classes/_mocks_.pushermock.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":66,"kind":2048,"name":"unsubscribe","url":"classes/_mocks_.pushermock.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":67,"kind":2048,"name":"disconnect","url":"classes/_mocks_.pushermock.html#disconnect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"mocks\".PusherMock"},{"id":68,"kind":4194304,"name":"CallbackSignature","url":"modules/_mocks_.html#callbacksignature","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"mocks\""},{"id":69,"kind":65536,"name":"__type","url":"modules/_mocks_.html#callbacksignature.__type","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"mocks\".CallbackSignature"},{"id":70,"kind":1,"name":"\"usePusher\"","url":"modules/_usepusher_.html","classes":"tsd-kind-external-module"},{"id":71,"kind":64,"name":"usePusher","url":"modules/_usepusher_.html#usepusher","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"usePusher\""},{"id":72,"kind":32,"name":"NOT_IN_CONTEXT_WARNING","url":"modules/_usepusher_.html#not_in_context_warning","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"usePusher\""},{"id":73,"kind":1,"name":"\"useChannel\"","url":"modules/_usechannel_.html","classes":"tsd-kind-external-module"},{"id":74,"kind":64,"name":"useChannel","url":"modules/_usechannel_.html#usechannel","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"useChannel\""},{"id":75,"kind":1,"name":"\"useClientTrigger\"","url":"modules/_useclienttrigger_.html","classes":"tsd-kind-external-module"},{"id":76,"kind":64,"name":"useClientTrigger","url":"modules/_useclienttrigger_.html#useclienttrigger","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"useClientTrigger\""},{"id":77,"kind":1,"name":"\"useEvent\"","url":"modules/_useevent_.html","classes":"tsd-kind-external-module"},{"id":78,"kind":64,"name":"useEvent","url":"modules/_useevent_.html#useevent","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"useEvent\""},{"id":79,"kind":1,"name":"\"usePresenceChannel\"","url":"modules/_usepresencechannel_.html","classes":"tsd-kind-external-module"},{"id":80,"kind":64,"name":"usePresenceChannel","url":"modules/_usepresencechannel_.html#usepresencechannel","classes":"tsd-kind-function tsd-parent-kind-external-module","parent":"\"usePresenceChannel\""},{"id":81,"kind":1,"name":"\"useTrigger\"","url":"modules/_usetrigger_.html","classes":"tsd-kind-external-module"},{"id":82,"kind":64,"name":"useTrigger","url":"modules/_usetrigger_.html#usetrigger","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"useTrigger\""}]}; \ No newline at end of file diff --git a/docs/classes/_mocks_.pusherchannelmock.html b/docs/classes/_mocks_.pusherchannelmock.html index 0666b18..2ac2261 100644 --- a/docs/classes/_mocks_.pusherchannelmock.html +++ b/docs/classes/_mocks_.pusherchannelmock.html @@ -123,7 +123,7 @@

constructor

  • Parameters

    @@ -145,7 +145,7 @@

    callbacks

    callbacks: {}
    @@ -157,7 +157,7 @@

    callbacks

    Type declaration

    @@ -168,7 +168,7 @@

    name

    name: string
    @@ -179,13 +179,13 @@

    Methods

    bind

      -
    • bind(name: string, callback: Function): void
    • +
    • bind(name: string, callback: CallbackSignature): void
    diff --git a/docs/classes/_mocks_.pusherpresencechannelmock.html b/docs/classes/_mocks_.pusherpresencechannelmock.html index 13f6a34..f53e0a9 100644 --- a/docs/classes/_mocks_.pusherpresencechannelmock.html +++ b/docs/classes/_mocks_.pusherpresencechannelmock.html @@ -126,7 +126,7 @@

    constructor

    Parameters

    @@ -149,7 +149,7 @@

    callbacks

    @@ -161,7 +161,7 @@

    callbacks

    Type declaration

    @@ -172,7 +172,7 @@

    members

    members: any
    @@ -182,7 +182,7 @@

    myID

    myID: any
    @@ -193,7 +193,7 @@

    name

    @@ -204,14 +204,14 @@

    Methods

    bind

      -
    • bind(name: string, callback: Function): void
    • +
    • bind(name: string, callback: CallbackSignature): void
    diff --git a/docs/interfaces/_types_.pusherproviderprops.html b/docs/interfaces/_types_.pusherproviderprops.html index 2b101ea..9ba6ff3 100644 --- a/docs/interfaces/_types_.pusherproviderprops.html +++ b/docs/interfaces/_types_.pusherproviderprops.html @@ -90,11 +90,10 @@

    Index

    Properties

    -
    +

    Optional auth

    auth: AuthOptions
    -
    +

    Optional authEndpoint

    authEndpoint: undefined | string
    @@ -180,34 +179,24 @@

    Optional authorizer

    -
    - -

    children

    -
    children: React.ReactNode
    - -

    clientKey

    clientKey: string

    cluster

    -
    cluster: string
    +
    cluster: "mt1" | "us2" | "us3" | "eu" | "ap1" | "ap2" | "ap3" | "ap4"
    @@ -217,7 +206,7 @@

    Optional defer

    defer: undefined | false | true
    @@ -370,7 +359,7 @@

    Optional triggerEndpoint<
    triggerEndpoint: undefined | string
    @@ -388,10 +377,10 @@

    Optional unavailable_time

    Optional value

    -
    value: any
    +
    @@ -489,10 +478,10 @@

    Optional wssPort

  • activityTimeout
  • -
  • +
  • auth
  • -
  • +
  • authEndpoint
  • @@ -501,9 +490,6 @@

    Optional wssPort

  • authorizer
  • -
  • - children -
  • clientKey
  • @@ -577,9 +563,6 @@

    Optional wssPort

    diff --git a/docs/interfaces/_types_.usechanneloptions.html b/docs/interfaces/_types_.usechanneloptions.html deleted file mode 100644 index 0b7399e..0000000 --- a/docs/interfaces/_types_.usechanneloptions.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - useChannelOptions | @harelpls/use-pusher - - - - - -
    -
    -
    -
    - -
    -
    - Options -
    -
    - All -
      -
    • Public
    • -
    • Public/Protected
    • -
    • All
    • -
    -
    - - - - - - -
    -
    - Menu -
    -
    -
    -
    -
    -
    - -

    Interface useChannelOptions

    -
    -
    -
    -
    -
    -
    -
    -

    Hierarchy

    -
      -
    • - useChannelOptions -
    • -
    -
    -
    -

    Index

    -
    -
    -
    -

    Properties

    - -
    -
    -
    -
    -
    -

    Properties

    -
    - -

    Optional skip

    -
    skip: undefined | false | true
    - -
    -
    -
    - -
    -
    -
    -
    -

    Legend

    -
    -
      -
    • Module
    • -
    • Object literal
    • -
    • Variable
    • -
    • Function
    • -
    • Function with type parameter
    • -
    • Index signature
    • -
    • Type alias
    • -
    • Type alias with type parameter
    • -
    -
      -
    • Enumeration
    • -
    • Enumeration member
    • -
    • Property
    • -
    • Method
    • -
    -
      -
    • Interface
    • -
    • Interface with type parameter
    • -
    • Constructor
    • -
    • Property
    • -
    • Method
    • -
    • Index signature
    • -
    -
      -
    • Class
    • -
    • Class with type parameter
    • -
    • Constructor
    • -
    • Property
    • -
    • Method
    • -
    • Accessor
    • -
    • Index signature
    • -
    -
      -
    • Inherited constructor
    • -
    • Inherited property
    • -
    • Inherited method
    • -
    • Inherited accessor
    • -
    -
      -
    • Protected property
    • -
    • Protected method
    • -
    • Protected accessor
    • -
    -
      -
    • Private property
    • -
    • Private method
    • -
    • Private accessor
    • -
    -
      -
    • Static property
    • -
    • Static method
    • -
    -
    -
    -
    -
    -

    Generated using TypeDoc

    -
    -
    - - - - \ No newline at end of file diff --git a/docs/modules/_mocks_.html b/docs/modules/_mocks_.html index 8fcbc6a..7bbb8b0 100644 --- a/docs/modules/_mocks_.html +++ b/docs/modules/_mocks_.html @@ -78,6 +78,49 @@

    Classes

  • PusherPresenceChannelMock
  • +
    +

    Type aliases

    + +
    + + + +
    +

    Type aliases

    +
    + +

    CallbackSignature

    +
    CallbackSignature: (data: any, metadata?: any) => void
    + +
    +

    Type declaration

    +
      +
    • +
        +
      • (data: any, metadata?: any): void
      • +
      +
        +
      • +

        Parameters

        +
          +
        • +
          data: any
          +
        • +
        • +
          Optional metadata: any
          +
        • +
        +

        Returns void

        +
      • +
      +
    • +
    @@ -128,6 +171,9 @@

    Classes

  • PusherPresenceChannelMock
  • +
  • + CallbackSignature +
  • diff --git a/docs/modules/_pusherprovider_.html b/docs/modules/_pusherprovider_.html index 192057b..728727d 100644 --- a/docs/modules/_pusherprovider_.html +++ b/docs/modules/_pusherprovider_.html @@ -94,7 +94,7 @@

    Const PusherContext

    PusherContext: Context<PusherContextValues> = React.createContext<PusherContextValues>({})
    @@ -104,7 +104,7 @@

    Const __PusherContext__PusherContext: Context<PusherContextValues> = PusherContext @@ -113,47 +113,43 @@

    Const __PusherContextFunctions

    -

    PusherProvider

    +

    Const PusherProvider

      -
    • PusherProvider(__namedParameters: { auth: undefined | AuthOptions; authEndpoint: undefined | string; clientKey: string; cluster: string; defer: boolean; props: props; triggerEndpoint: undefined | string }): Element
    • +
    • PusherProvider(__namedParameters: { children: undefined | null | string | number | false | true | {} | ReactElement<any, string | ((props: P) => ReactElement | null) | {}> | ReactNodeArray | ReactPortal; clientKey: string; cluster: "mt1" | "us2" | "us3" | "eu" | "ap1" | "ap2" | "ap3" | "ap4"; defer: boolean; props: props; triggerEndpoint: undefined | string }): Element
    • -

      Provider for the pusher service in an app

      +

      Provider that creates your pusher instance and provides it to child hooks throughout your app. + Note, you can pass in value={{}} as a prop if you'd like to override the pusher client passed. + This is handy when simulating pusher locally, or for testing.

      Parameters

      • -
        __namedParameters: { auth: undefined | AuthOptions; authEndpoint: undefined | string; clientKey: string; cluster: string; defer: boolean; props: props; triggerEndpoint: undefined | string }
        +
        __namedParameters: { children: undefined | null | string | number | false | true | {} | ReactElement<any, string | ((props: P) => ReactElement | null) | {}> | ReactNodeArray | ReactPortal; clientKey: string; cluster: "mt1" | "us2" | "us3" | "eu" | "ap1" | "ap2" | "ap3" | "ap4"; defer: boolean; props: props; triggerEndpoint: undefined | string }
        • -
          auth: undefined | AuthOptions
          -
        • -
        • -
          authEndpoint: undefined | string
          +
          children: undefined | null | string | number | false | true | {} | ReactElement<any, string | ((props: P) => ReactElement | null) | {}> | ReactNodeArray | ReactPortal
        • clientKey: string
        • -
          cluster: string
          +
          cluster: "mt1" | "us2" | "us3" | "eu" | "ap1" | "ap2" | "ap3" | "ap4"
        • defer: boolean
        • props: props
          -
          -

          Config for Pusher client

          -
        • triggerEndpoint: undefined | string
          diff --git a/docs/modules/_types_.html b/docs/modules/_types_.html index 557ec12..dcb2fe0 100644 --- a/docs/modules/_types_.html +++ b/docs/modules/_types_.html @@ -75,7 +75,6 @@

          Interfaces

    @@ -125,9 +124,6 @@

    Interfaces

  • PusherProviderProps
  • -
  • - useChannelOptions -
  • diff --git a/docs/modules/_usechannel_.html b/docs/modules/_usechannel_.html index 69d4aa2..ad4024e 100644 --- a/docs/modules/_usechannel_.html +++ b/docs/modules/_usechannel_.html @@ -73,7 +73,7 @@

    Index

    Functions

    @@ -81,36 +81,50 @@

    Functions

    Functions

    -
    +

    useChannel

    -
      -
    • useChannel(channelName: string): any
    • +
        +
      • useChannel<T>(channelName: string): undefined | T
      • -

        Subscribe to channel

        +

        Subscribe to a channel

        +
        typeparam
        +

        of channel you're subscribing to. Can be one of Channel or PresenceChannel from pusher-js.

        +
        example
        -

        useChannel("my-channel")

        +
        const channel = useChannel("my-channel")
        +channel.bind('some-event', () => {})
        +

        Type parameters

        +
          +
        • +

          T: Channel & PresenceChannel

          +
        • +

        Parameters

        • channelName: string
          +
          +

          The name of the channel you want to subscribe to.

          +
        -

        Returns any

        +

        Returns undefined | T

        +

        Instance of the channel you just subscribed to.

    @@ -153,7 +167,7 @@

    Returns any

    Functions

    -
    +

    useClientTrigger

    -
      -
    • useClientTrigger(channel: Channel | PresenceChannel): (Anonymous function)
    • +
        +
      • useClientTrigger<TData>(channel: Channel | PresenceChannel): (Anonymous function)
      • +
        +
        +
        example
        +
        const channel = useChannel('my-channel');
        +const trigger = useClientTrigger(channel)
        +
        +const handleClick = () => trigger('some-client-event', {});
        +
        +
        +
        +

        Type parameters

        +
          +
        • +

          TData

          +
          +

          shape of the data you're sending with the event.

          +
          +
        • +

        Parameters

        • channel: Channel | PresenceChannel
          +
          +

          the channel you'd like to trigger clientEvents on. Get this from useChannel or usePresenceChannel.

          +

        Returns (Anonymous function)

        +

        A memoized trigger function that will perform client events on the channel.

    @@ -143,7 +166,7 @@

    Returns (Anonymou

    @@ -110,21 +110,22 @@

    usePusher

  • -

    Provides access to the pusher client

    +

    Provides access to the pusher client instance.

    example
    -

    const {client} = usePusher(); - client.current.subscribe('my-channel');

    +
    const { client } = usePusher();
    +client.current.subscribe('my-channel');

    Returns PusherContextValues

    +

    a MutableRefObject<Pusher|undefined>. The instance is held by a useRef() hook.

  • diff --git a/docs/modules/_usetrigger_.html b/docs/modules/_usetrigger_.html index 36d6e0b..acf145c 100644 --- a/docs/modules/_usetrigger_.html +++ b/docs/modules/_usetrigger_.html @@ -73,7 +73,7 @@

    Index

    Functions

    @@ -81,34 +81,47 @@

    Functions

    Functions

    -
    +

    useTrigger

    -
      -
    • useTrigger(channelName: string): (Anonymous function)
    • +
        +
      • useTrigger<TData>(channelName: string): (Anonymous function)
      • -

        Trigger events hook

        +

        Hook to provide a trigger function that calls the server defined in PusherProviderProps.triggerEndpoint using fetch. + Any auth?.headers in the config object will be passed with the fetch call.

        example
        -

        const trigger = useTrigger('my-channel'); - trigger('my-event', {message: 'hello'});

        +
        const trigger = useTrigger<{message: string}>('my-channel');
        +trigger('my-event', {message: 'hello'});
        +

        Type parameters

        +
          +
        • +

          TData

          +
          +

          shape of the data you're sending with the event

          +
          +
        • +

        Parameters

        • channelName: string
          +
          +

          name of channel to call trigger on

          +

        Returns (Anonymous function)

        @@ -154,7 +167,7 @@

        Returns (Anonymou