You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the usage of injectParams is as follows:
id=injectParams('id');// Signal<unknown>
This results in a signal of type unknown, requiring manual parsing and transformation in subsequent steps. I propose adding an option to include a transformation function as part of the injectParams method, enabling direct casting or processing of the parameter.
Desired Functionality:
I would like to use injectParams in a way that allows for the automatic transformation of the parameters, for example:
This feature would allow developers to specify a transformation function (such as toNumber(), toBoolean(), or a custom function), which would be applied to the value of the parameter before it is returned as a signal.
Benefits:
Cleaner Code: Reduces the need for repetitive transformation logic in the component, resulting in more concise and readable code.
Type Safety: By applying a transformation function, the type of the returned signal can be strictly typed (e.g., Signal<number>), reducing type uncertainty and errors during development.
Customizability: Developers could provide custom transformation functions, offering greater flexibility when handling URL parameters.
This proposal would allow developers to effortlessly transform and type URL parameters in a declarative and reusable way.
Conclusion:
This enhancement would improve developer experience by simplifying parameter handling and ensuring better type safety, while maintaining flexibility through optional transformation functions.
The text was updated successfully, but these errors were encountered:
Life has gotten in the way of me finishing the PR, so if you'd like, feel free to take it from here. Docs and tests are still missing, but the core is mostly done.
Description:
Currently, the usage of
injectParams
is as follows:This results in a signal of type
unknown
, requiring manual parsing and transformation in subsequent steps. I propose adding an option to include a transformation function as part of theinjectParams
method, enabling direct casting or processing of the parameter.Desired Functionality:
I would like to use
injectParams
in a way that allows for the automatic transformation of the parameters, for example:This feature would allow developers to specify a transformation function (such as
toNumber()
,toBoolean()
, or a custom function), which would be applied to the value of the parameter before it is returned as a signal.Benefits:
Signal<number>
), reducing type uncertainty and errors during development.Proposed API:
The
options
parameter would be optional, and thetransform
function would apply the provided transformation to the parameter value, if specified.Example Usage:
This proposal would allow developers to effortlessly transform and type URL parameters in a declarative and reusable way.
Conclusion:
This enhancement would improve developer experience by simplifying parameter handling and ensuring better type safety, while maintaining flexibility through optional transformation functions.
The text was updated successfully, but these errors were encountered: