InjectionToken<...> for public providers in piral-ng #703
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
New Feature Proposal
Add typed
InjectionToken<...>
constants topiral-ng
and use them when providingpiral
,Props
andContext
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:
module.ts
:piral/src/converters/piral-ng/src/module.ts
Line 40 in 1c113ff
standalone.ts
:piral/src/converters/piral-ng/src/standalone.ts
Line 49 in 1c113ff
Background
Some application developers prefer the new
inject(...)
funtion over the classic@Inject(...)
annotation.inject
is typed more strictly, it does not allow a simplestring
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 asprovide
key, developers currently can not use the theinject
function without using type-avoiding hacks (likeinject('piral' as any)
).Example
The following is an ad-hoc change, without even compiling/building Piral.
hwanders@84347a9
The text was updated successfully, but these errors were encountered: