-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Expressions Plugin] Allow render definitions with extended IInterpreterRenderHandlers #74133
Comments
Pinging @elastic/kibana-app-arch (Team:AppArch) |
We could consider adding an optional type parameter to interface MyHandlers extends IInterpreterRenderHandlers {
hello: () => void;
}
const myRenderer: ExpressionRenderDefinition<Config, MyHandlers> = {}; The generic Would that work for you @crob611? AFAICT this shouldn't be a problem, but would need to test it. |
I experimented with that. The problem I hit then was at the I didn't dig much after that and just bailed things on our end and explicitly casted our stuff to I'm starting to think maybe handlers isn't the correct place for us to add additional handler functionality? |
Ah, I had missed that. So in that case we'd also need to make |
Yeah, @ppisljar and I talked about this a bit and I believe he's planning to follow up with some thoughts on how to address what you are looking to do. |
Just for reference: We create the handlers that we pass into the render functions in create_handlers.ts We just have empty stubs for most of the methods defined by We pass them through to the render function in render_with_fn |
The reason we didn't allow extending the handlers definition is that we need a fixed (agreed upon) set of handlers that every renderer consumes as else the renderers are not usable outside of specific context. If we don't know what handlers the specific renderer requires its impossible to consume it. I opened an issue for addressing the current extra handlers that canvas is passing into expressions here: #74644 i think we should try to address that as soon as possible. I think reusability is one of the main advantages of expressions and we should really try hard to make all functions and renderers reusable. |
closing this in favor of #74644 |
Canvas was trying to type all of our render definitions, but we have some extra handlers that we define to extend IInterpreterRenderHandlers.
Defining our renderers with a render function with the handlers typed to our HandlerType causes a type error when trying to add to the registry due to those handlers being mismatched with the IInterpreterRenderHandlers.
Is there a way to relax the type on ExpressionRenderDefinition to allow additional handlers? Or is there a different way we should be going about adding additional handlers?
The text was updated successfully, but these errors were encountered: