Last active
October 14, 2020 13:36
-
-
Save ljmotta/f6236696e90ae730ed6257c1cec64664 to your computer and use it in GitHub Desktop.
EmbeddedTodoList Ref Delegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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