14.217.0 • Published 9 months ago

@genesislcap/foundation-broadcast-channel v14.217.0

Weekly downloads
-
License
SEE LICENSE IN li...
Repository
github
Last release
9 months ago

Foundation Broadcast Channel

lerna TypeScript

foundation-broadcast-channel provides a strongly typed Broadcast_Channel API and related utilities. The system uses the same event typing we use in our stores, where the key is the event, and the value is the details or payload if any.

Installation

To enable this module in your application, follow the steps below.

  1. Add @genesislcap/foundation-broadcast-channel as a dependency in your package.json file.

Note whenever you change the dependencies of your project, ensure you run the $ npm run bootstrap command again, or npm i, depending on your setup. You can find more information in the package.json basics page.

{
  "dependencies": {
    "@genesislcap/foundation-broadcast-channel": "latest",
    ...
  }
}

Usage

Create a typed channel for your application or package, likely in a config.ts file.

import { registerTypedBroadcastChannel, TypedBroadcastChannel } from '@genesislcap/foundation-broadcast-channel';

// Define or import the channel event / message map
export type GenesisResourcesEvents = {
  'resources-loaded': ResourceItem[];
  'resources-unloaded': void;
};

// Define the interface
export interface GenesisResourcesChannel extends TypedBroadcastChannel<GenesisResourcesEvents> {}

// Define the DI key
export const GenesisResourcesChannel = registerTypedBroadcastChannel<GenesisResourcesEvents>(GenesisResourcesChannelId);

Inject the channel into the actors you wish to post broadcast messages from.

import { GenesisResourcesChannel } from '@genesislcap/foundation-comms';

constructor(@GenesisResourcesChannel protected channel: GenesisResourcesChannel) {}

// Broadcast strongly typed messages
this.channel.postMessage('resources-loaded', this.resources);

Inject the channel into the actors you wish to recieve broadcast messages from.

import { GenesisResourcesChannel } from '@genesislcap/foundation-comms';

@GenesisResourcesChannel protected channel: GenesisResourcesChannel;

// Handle broadcasted messages and use the provided type narrowing API
this.channel.onmessage = (ev) => {
  if (this.channel.isMessageType('resources-loaded', ev)) {
    // Typescript now knows what detail is
    if (!ev.data.detail.length) {
      throw Error('No backend resources available');
    }
  }
};

// Close the channel when finished, perhaps on disconnectedCallback
this.channel.close();

Note that injected channels are transient by design.

API Docs

License

Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact Genesis Global for more details.

Licensed components

Genesis low-code platform

14.217.0

9 months ago

14.215.1

9 months ago

14.216.0

9 months ago

14.214.4-cr.cr-1

9 months ago

14.215.0

9 months ago

14.214.4

9 months ago

14.214.3

9 months ago

14.214.2

9 months ago

14.214.1

9 months ago

14.214.0

9 months ago

14.213.0

9 months ago

14.213.1

9 months ago

14.210.3

10 months ago

14.210.2

10 months ago

14.210.1

10 months ago

14.210.0

10 months ago

14.210.5

9 months ago

14.210.4

10 months ago

14.211.2

9 months ago

14.211.1

9 months ago

14.211.0

9 months ago

14.211.5

9 months ago

14.211.4

9 months ago

14.211.3

9 months ago

14.212.0

9 months ago

14.209.2

10 months ago

14.209.1

10 months ago

14.208.3

10 months ago

14.208.2

10 months ago

14.209.0

10 months ago

14.208.1

10 months ago

14.207.1

10 months ago

14.207.2

10 months ago

14.207.3

10 months ago

14.208.0

10 months ago

14.206.1

10 months ago

14.206.2

10 months ago

14.206.3

10 months ago

14.206.4

10 months ago

14.207.0

10 months ago

14.204.1-FUI-2179.1

10 months ago

14.206.0

11 months ago

14.205.0-jsdom.1

11 months ago

14.205.1

11 months ago

14.205.0

11 months ago

14.204.0

11 months ago

14.204.1

11 months ago

14.203.2

11 months ago

14.196.1

12 months ago

14.196.0

12 months ago

14.192.1

1 year ago

14.192.2

1 year ago

14.192.0

1 year ago

14.200.0-FUI-2127.3

11 months ago

14.200.0-FUI-2127.4

11 months ago

14.202.0

11 months ago

14.180.6

1 year ago

14.180.7

1 year ago

14.184.0

1 year ago

14.197.0-ng.2

12 months ago

14.188.0

1 year ago

14.180.8

1 year ago

14.190.0-FUI-2012.1

12 months ago

14.197.0

12 months ago

14.197.1

12 months ago

14.193.2

1 year ago

14.193.3

1 year ago

14.193.0

1 year ago

14.193.1

1 year ago

14.203.0

11 months ago

14.203.1

11 months ago

14.200.0-FUI-2127.2

11 months ago

14.185.0

1 year ago

14.181.1

1 year ago

14.181.0

1 year ago

14.189.0

1 year ago

14.195.3-FUI-2102.1

12 months ago

14.195.3-FUI-2102.2

12 months ago

14.195.3-FUI-2102.3

12 months ago

14.194.3

1 year ago

14.198.0

12 months ago

14.194.4

1 year ago

14.194.1

1 year ago

14.194.2

1 year ago

14.194.0

1 year ago

14.194.7

1 year ago

14.194.5

1 year ago

14.194.6

1 year ago

14.200.0

11 months ago

14.197.0-FUI-2106.2

12 months ago

14.197.0-FUI-2106.1

12 months ago

14.195.3-FUI-2102.4

12 months ago

14.186.0

1 year ago

14.195.3-FUI-2102.5

12 months ago

14.186.1

1 year ago

14.182.2

1 year ago

14.182.0

1 year ago

14.182.1

1 year ago

14.192.2-FUI-2127.1

11 months ago

14.195.2

12 months ago

14.195.3

12 months ago

14.195.0

1 year ago

14.195.1

1 year ago

14.191.0

1 year ago

14.191.1

1 year ago

14.199.2

11 months ago

14.199.0

12 months ago

14.199.1

12 months ago

14.201.0

11 months ago

14.192.2-axes.2

1 year ago

14.190.0

1 year ago

14.183.3

1 year ago

14.187.0

1 year ago

14.183.4

1 year ago

14.183.1

1 year ago

14.183.2

1 year ago

14.183.0

1 year ago

14.183.7

1 year ago

14.187.1

1 year ago

14.183.5

1 year ago

14.183.6

1 year ago

14.180.4

1 year ago

14.180.5

1 year ago

14.180.2

1 year ago

14.180.3

1 year ago

14.179.0

1 year ago

14.180.0

1 year ago

14.180.1

1 year ago

14.178.0

1 year ago

14.177.3

1 year ago

14.177.2

1 year ago

14.177.1

1 year ago

14.177.0

1 year ago

14.176.0

1 year ago

14.175.0

1 year ago

14.174.0

1 year ago

14.173.4

1 year ago

14.173.3

1 year ago

14.173.2

1 year ago

14.173.1

1 year ago

14.173.0

1 year ago

14.172.3

1 year ago

14.172.2

1 year ago

14.172.1

1 year ago

14.172.0

1 year ago