npm.io
9.3.0 • Published 3m ago

@availity/message-core

Licence
MIT
Version
9.3.0
Deps
0
Size
29 kB
Vulns
0
Weekly
0
Stars
13

@availity/message-core

A package wrapping the postMessage function with helper functions and security checks.

Version NPM Downloads Dependecy Status

Install

NPM

npm install @availity/message-core
Yarn
yarn add @availity/message-core

Usage

The default export is a pre-configured AvMessage instance for cross-frame communication within the Availity portal.

import avMessage from '@availity/message-core';

// Send a message to the parent window
avMessage.send({ event: 'my-event', data: { key: 'value' } });

// Subscribe to messages
const unsubscribe = avMessage.subscribe('my-event', (data) => {
  console.log('Received:', data);
});

// Unsubscribe when done
unsubscribe();

// Or unsubscribe by event name
avMessage.unsubscribe('my-event');

// Remove all subscribers
avMessage.unsubscribeAll();

// Enable or disable message handling
avMessage.enabled(false);

// Clean up when your app/component unmounts
avMessage.destroy();

Messages are validated against trusted Availity domains for security.

Documentation

Check out more documentation at availity.github.io

Keywords