Skip to content

Introduce @params and @queryParams and @props for react withViewModel #351

@woksin

Description

@woksin

For the WellKnownBindings we can introduce a wrapper decorator. This decorator can then encapsulate the @inject decorator from tsyringe.

In addition to this it can get the type of the parameter it is decorating. If this type is a class type, we will have more information to be able to have proper types on query-params and route-params.

The type (constructor info) is something the decorator store on the target type (typically the viewModel). This can be stored in a field on target type, typically something like : __routeParamsType and __queryParamsType. In the withViewModel() we can then look for these on the viewModel type and then bind in the container using a callback, the callback will then deserialize params based on the types of the properties in the params type. This would depend on the @Field decorator being set on properties.

From this we can simply use the Fundamentals JsonSerializer. The process would be to populate an untyped any object with all the properties from the origin, which are typically represented as strings. Then call the deserializeFromInstance() on JsonSerializer using the __routeParamsType or __queryParamsType.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions