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

InjectionToken<...> for public providers in piral-ng #703

Closed
hwanders opened this issue Jul 20, 2024 · 1 comment · Fixed by #704
Closed

InjectionToken<...> for public providers in piral-ng #703

hwanders opened this issue Jul 20, 2024 · 1 comment · Fixed by #704
Labels
angular Concerns the Angular integration piral-ng. enhancement New feature or request help wanted Extra attention is needed in-review The item is currently being reviewed.
Milestone

Comments

@hwanders
Copy link
Contributor

hwanders commented Jul 20, 2024

New Feature Proposal

Add typed InjectionToken<...> constants to piral-ng and use them when providing piral, Props and Context using those tokens in the dependency injection container.

Description

For downward-compatibility the string-based providers should probably be kept.
The relevant source code parts are:

Background

Some application developers prefer the new inject(...) funtion over the classic @Inject(...) annotation.
inject is typed more strictly, it does not allow a simple string parameter anymore, like @Inject.
So writing inject('piral') will fail in a type checking error.

Since the token passed to inject must exactly match the one used as provide key, developers currently can not use the the inject function without using type-avoiding hacks (like inject('piral' as any)).

Example

The following is an ad-hoc change, without even compiling/building Piral.
hwanders@84347a9

@hwanders hwanders added the enhancement New feature or request label Jul 20, 2024
@hwanders hwanders changed the title Offer typed InjectionTokens in piral-ng for inject function InjectionToken<...> for public providers in piral-ng Jul 20, 2024
@FlorianRappl FlorianRappl added help wanted Extra attention is needed angular Concerns the Angular integration piral-ng. in-review The item is currently being reviewed. labels Jul 20, 2024
@FlorianRappl
Copy link
Contributor

Sounds great - want to make a PR?

@FlorianRappl FlorianRappl added this to the 1.6.1 milestone Jul 20, 2024
FlorianRappl added a commit that referenced this issue Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular Concerns the Angular integration piral-ng. enhancement New feature or request help wanted Extra attention is needed in-review The item is currently being reviewed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants