Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Last active October 14, 2020 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljmotta/deef6a2ebabd274a605da0a094e9cb95 to your computer and use it in GitHub Desktop.
Save ljmotta/deef6a2ebabd274a605da0a094e9cb95 to your computer and use it in GitHub Desktop.
TodoListEnvelope Envelope View Delegate
import { TodoListEnvelopeView, TodoListEnvelopeViewApi } from "./TodoListEnvelopeView";
export function init(args: { container: HTMLElement; bus: EnvelopeBus }) {
// ...
const envelopeViewDelegate = async () => {
const ref = React.createRef<TodoListEnvelopeViewApi>();
return new Promise<() => TodoListEnvelopeViewApi>((res) =>
ReactDOM.render(<TodoListEnvelopeView ref={ref} channelApi={envelope.channelApi} />, args.container, () =>
res(() => ref.current!)
)
);
};
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment