Skip to content

Add Overloads for UseElectron #1076

@AeonSake

Description

@AeonSake

It would be great to have some method overloads for the UseElectron extension method, specifically the following:

UseElectron(string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
UseElectron(string[] args, Func<string[], Task> onAppReadyCallback)
UseElectron(string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)

Both, WebApplicationBuilderExtensions and WebHostBuilderExtensions, would need these overloads.

Motivation

The current implementation requires the callback task to be ready before the app is instantiated, i.e., before the service collection is initialized. This can cause issues, especially when the callback comes from a service. For that, it would be great to have an overload that allows access to the IServiceCollection, similarly to how the service collection factory pattern works. This allows the normal dependency injection logic to fully resolve the required services on demand, rather than having it initialized beforehand. Furthermore, having access to the arguments at that stage rather than having to pipe them through yourself would also reduce friction.
From what I can tell, the internal ElectronNetRuntime.OnAppReadyCallback is not executed before the app is instantiated which means, the fully initialized service collection would be available at that time.

On a side-note: the argument array has to be provided on the initial UseElectron method, but is never actually used?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions