Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Last active October 14, 2020 13:36
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/f6236696e90ae730ed6257c1cec64664 to your computer and use it in GitHub Desktop.
Save ljmotta/f6236696e90ae730ed6257c1cec64664 to your computer and use it in GitHub Desktop.
EmbeddedTodoList Ref Delegate
import { EnvelopeServer } from "@kogito-tooling/envelope-bus/dist/channel";
import { TodoListApi, TodoListChannelApi, TodoListEnvelopeApi } from "../api";
export const EmbeddedTodoList = React.forwardRef<TodoListApi, Props>((props, forwardedRef) => {
// ...
const refDelegate = useCallback(
(envelopeServer: EnvelopeServer<TodoListChannelApi, TodoListEnvelopeApi>): TodoListApi => ({
addItem: (item) => envelopeServer.envelopeApi.requests.todoList__addItem(item),
getItems: () => envelopeServer.envelopeApi.requests.todoList__getItems(),
markAllAsCompleted: () => envelopeServer.envelopeApi.notifications.todoList__markAllAsCompleted(),
}),
[]
);
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment