Skip to content

add source generator for creating/binding to events of a IJSInProcessObjectReference/IJSObjectReference #68094

Description

@The3G

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I would like to listen to events of a IJSInProcessObjectReference/IJSObjectReference without the need for handcrafting or managing the registration of the javascript EventListener and/or callback.

Describe the solution you'd like

a source generator that allows the creation and/management of event listeners and dotnet callbacks that hook into .NET EventHandler

public event EventHandle<EventTypeArg> EventName;

IJSInProcessRuntime _runtime;
IJSInProcessObjectReference _instanceHandle = _runtime.InvokeConstructor("objectType", ...);

// source generator would detect and generate the c# and javascript interop to create,
// manage and release the _instanceHandle (EventTarget) EventListener including the disposing.
_instanceHandle.Bind("event-name", EventName);

Additional context

It seem logic to have this added to the blazor interop functionality to make use of the same event listern management/tracking system that is used by blazor for components and html elements and given the base javascript EventTarget class is used for both html and non-html element and to provide the event listern bindings/release/dispatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions