Skip to content
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

Add new variant for OnAfterRender handler bound in server-side code #250

Open
granicz opened this issue Oct 21, 2022 · 0 comments
Open

Add new variant for OnAfterRender handler bound in server-side code #250

granicz opened this issue Oct 21, 2022 · 0 comments

Comments

@granicz
Copy link
Member

granicz commented Oct 21, 2022

Currently, the templating TP generates the following event handler variants for binding OnAfterRender events:

image

This, however, runs into problems with disambiguation, so code like this doesn't type check properly, like it does with regular events:

Templates.MainTemplate()
    .OAR(fun e ->  // <- FAILS to infer the type of e
        let n = e.Anchors.Parent
        ...
    )

Instead, one has to type annotate the handler argument, which gets pretty annoying:

Templates.MainTemplate()
    .OAR(fun (e: Runtime.Server.TemplateEvent<Templates.MainTemplate.Vars, Templates.MainTemplate.Anchors, JavaScript.Dom.Event>) ->
       ...

I even found that trying to save on the type arguments causes a mismatch:

image

So the current proposal is to generate an addition member for each OAR handler, named as <event-name>_WithModel, with the same signature as the existing variant (TemplateEvent<...> -> unit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants