Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PingPongEnvelope
import { EnvelopeBus } from "@kogito-tooling/envelope-bus/dist/api";
import { Envelope } from "@kogito-tooling/envelope";
import { PingPongChannelApi, PingPongEnvelopeApi } from "../api";
// ...
export function init(args: { container: HTMLElement; bus: EnvelopeBus; pingPongViewFactory: PingPongFactory }) {
const envelope = new Envelope<
PingPongEnvelopeApi,
PingPongChannelApi,
PingPongEnvelopeViewApi,
PingPongEnvelopeContext
>(args.bus);
const envelopeViewDelegate = async () => {
const ref = React.createRef<PingPongEnvelopeViewApi>();
return new Promise<() => PingPongEnvelopeViewApi>((res) =>
ReactDOM.render(<PingPongEnvelopeView ref={ref} />, args.container, () => res(() => ref.current!))
);
};
const context: PingPongEnvelopeContext = {};
return envelope.start(envelopeViewDelegate, context, {
create: (apiFactoryArgs) => new PingPongEnvelopeApiImpl(apiFactoryArgs, args.pingPongViewFactory),
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.