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

Dependency injection: better support for non-UIComponent types #104

Closed
5 tasks done
jonisavo opened this issue Jul 4, 2023 · 0 comments
Closed
5 tasks done

Dependency injection: better support for non-UIComponent types #104

jonisavo opened this issue Jul 4, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@jonisavo
Copy link
Owner

jonisavo commented Jul 4, 2023

At the moment, dependency injection is designed for UIComponents. It can be used with other types, but it is very tedious. The following should be as easy as possible to implement:

// interfaces are omitted for brevity

public class MySecondDependency { /* code */ }

[Dependency(typeof(IMySecondDependency), provide: typeof(MySecondDependency))]
public class MyFirstDependency { /* code */ }

[Dependency(typeof(IMyFirstDependency), provide: typeof(MyFirstDependency))]
public class MyComponent : UIComponent { /* code */ }

One possible approach would be to introduce a new class that could be inherited from. It would contain the minimum code needed to get dependency injection working.

Furthermore, TestBed should be modified to work with all dependency consumers.

  • Don't require Logger with dependency injection
  • Create subclass for DI consumers
  • Look into DI without interfaces
  • Rework TestBed to accept non-UIComponent types
  • Update documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant