Events
Emitting an event
import type { const root: Root
A gref to the root of this program.
root } from "membrane";
export function function endpoint(req: any): void
endpoint(req: any
req) { switch (`${req: any
req.any
method} ${req: any
req.any
path}`) { case "POST /gh-webhook-path": const root: Root
A gref to the root of this program.
root.any
ghWebhookReceived.any
$emit(); /* ... */ }};
Subscribing to an event
Programs can subscribe an action to handle an event. When an event is emitted, the action will be invoked with an additional parameter called event
.
import type { import nodes
nodes } from "membrane";
export async function function sendToSlack(_: any, { event }: { event: any;}): Promise<void>
sendToSlack(_: any
_, { event: any
event }) { await import nodes
nodes.any
slack.any
channel(/* ... */).any
sendMessage(/* ... */);}
export async function function configure(): Promise<void>
configure() { import nodes
nodes.any
ghWebhookReceived.any
$subscribe(function sendToSlack(_: any, { event }: { event: any;}): Promise<void>
sendToSlack);}