PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.75
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.75
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / scripts / iframe / useBackgroundApp.ts

useBackgroundApp.ts in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.75, at scripts/iframe/useBackgroundApp.ts

30 lines 700 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createContext, useContext } from 'react';
2 import {
3 deviceId,
4 hubspotBaseUrl,
5 locale,
6 portalId,
7 } from '../constants/leadinConfig';
8 import { Message } from './messageMiddleware';
9
10 export const BackgroudAppContext = createContext<any>(null);
11
12 export function useBackgroundAppContext() {
13 return useContext(BackgroudAppContext);
14 }
15
16 export function usePostBackgroundMessage() {
17 const app = useBackgroundAppContext();
18
19 return (message: Message) => {
20 app.postMessage(message);
21 };
22 }
23
24 export function usePostAsyncBackgroundMessage(): (
25 message: Message
26 ) => Promise<any> {
27 const app = useBackgroundAppContext();
28 return (message: Message) => app.postAsyncMessage(message);
29 }
30