FDC3 Channel Event
This is a utility element that listens to an event on its parent element and broadcasts the event detail payload on an FDC3 Channel.
Use cases:
- Send event on system color channel
- Send event on app channel
- Map the event payload before broadcasting on a channel
FDC3 requires an FDC3 enabled browser to work.
The following are vendors of FDC3 enabled browsers that we support
Examples
The following example is based on the following kotlin code snippets.
It creates and serves an entity that matches the fdc3.position
schema
In your app-name-tables-dictionary.kts add:
tables {
table(name = "INSTRUMENT_REF", id = 11_000) {
field("INSTRUMENT_ID", LONG).autoIncrement()
field("INSTRUMENT_TYPE", STRING(100))
field("TICKER", STRING(100)).notNull()
field("ISIN", STRING(100))
field("CUSIP", STRING(100))
field("SEDOL", STRING(100))
field("FIGI_ID", STRING(100))
field("INSTRUMENT_NAME", STRING(100))
field("BASE_BID_PRICE", DOUBLE).notNull()
field("BASE_ASK_PRICE", DOUBLE).notNull()
field("BBG_ID", STRING(100))
field("FDS_ID", STRING(100))
field("PERMID", STRING(100))
field("RIC", STRING(100))
field("EXCHANGE", STRING(100))
field("CURRENCY", STRING(100))
field("COUNTRY", STRING(100))
primaryKey("INSTRUMENT_ID")
}
}
In your app-name-dataserver.kts add:
dataServer {
query("ALL_INSTRUMENT_REF", INSTRUMENT_REF)
}
Example 1 - Send event on system channel
This will listen to the rowClicked
event that is fired by the rapid-grid-pro
element whenever a row is clicked.
It will broadcast on the current system color channel.
It will broadcast with the context type fdc3.position
.
The context payload will contain the event.detail.data
payload in the id
property of the Context object.
- Genesis
- React
- Angular
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
@customElement({
name: 'my-element',
template: html`
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event event-name="rowClicked" channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
`,
})
export class MyElement extends GenesisElement {}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
export function MyComponent() {
return (
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event event-name="rowClicked" channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
);
}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'my-root',
templateUrl: './my.component.html',
template: `
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event event-name="rowClicked" channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
`,
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppComponent {}
Example 2 - Send event on app channel
This will listen to the rowClicked
event that is fired by the rapid-grid-pro
element whenever a row is clicked.
It will broadcast on the specified app channel, in this case appChannel
.
- Genesis
- React
- Angular
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
@customElement({
name: 'my-element',
template: html`
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
event-name="rowClicked"
channel-type="fdc3.position"
channel-name="appChannel">
</fdc3-channel-event>
</rapid-grid-pro>
`,
})
export class MyElement extends GenesisElement {}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
export function MyComponent() {
return (
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
event-name="rowClicked"
channel-type="fdc3.position"
channel-name="appChannel">
</fdc3-channel-event>
</rapid-grid-pro>
);
}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'my-root',
templateUrl: './my.component.html',
template: `
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
event-name="rowClicked"
channel-type="fdc3.position"
channel-name="appChannel">
</fdc3-channel-event>
</rapid-grid-pro>
`
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppComponent {}
Example 3 - Send mapped event on system channel
This will listen to the rowClicked
event that is fired by the rapid-grid-pro
element whenever a row is clicked.
It will broadcast on the current system color channel.
It will broadcast with the context type fdc3.position
.
The mapping function will map the event.detail.data
payload and create a new object.
- Genesis
- React
- Angular
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
@customElement({
name: 'my-element',
template: html`
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
:mappingFunction="${() => ({TICKER, CUSIP}) => ({ id: { ticker: TICKER, cusip: CUSIP } })}"
event-name="rowClicked"
channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
`,
})
export class MyElement extends GenesisElement {}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
export function MyComponent() {
const mappingFunction = (params: any) => ({ id: { ticker: params.TICKER, cusip: params.CUSIP } })
return (
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
mappingFunction={mappingFunction}
event-name="rowClicked"
channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
);
}
Declaration
<fdc3-channel-event></fdc3-channel-event>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'my-root',
templateUrl: `
<rapid-grid-pro>
<grid-pro-genesis-datasource
resource-name="ALL_INSTRUMENT_REF">
</grid-pro-genesis-datasource>
<fdc3-channel-event
[mappingFunction]="mappingFunction"
event-name="rowClicked"
channel-type="fdc3.position">
</fdc3-channel-event>
</rapid-grid-pro>
`,
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppComponent {
mappingFunction(params: any) {
return { id: { ticker: params.TICKER, cusip: params.CUSIP } };
}
}
DOM API
Property and attribute binding examples for Genesis Component syntax. Closing tag omitted.
Attributes
Attribute | Type | Use | Example |
---|---|---|---|
event-name | string | The name of the javascript event to listen to on the parent |
|
channel-type | string | The name of the channel context type that will be broadcast |
|
channel-name | string | If specified, the element will broadcast on a named app channel |
|
Properties
Property | Type | Use | Example |
---|---|---|---|
mappingFunction |
| An optional function to override the channel broadcast payload. It should be a function which returns a value, corresponding to the fdc3 type. It will receive the custom event detail.data property value (or detail if data is not present) as a parameter. The returned value will be broadcast on the channel |
|
Slots
This component has no slots.
Parts
This component has no parts.
Fired Events
This component doesn't fire any events.
Listened Events
This component listens to the event on its parent element that you specify in the event-name
attribute.