Skip to content

Change the RegistrationBuilder method signatures to use Component and FinalResult rather than [Registration] #24

@bbrk24

Description

@bbrk24

Checklist

Problem

The documentation for result builders lists the following methods:

  • buildBlock(_ components: Component...) -> Component
  • buildOptional(_ component: Component?) -> Component
  • buildEither(first: Component) -> Component and buildEither(second: Component) -> Component
  • buildArray(_ components: [Component]) -> Component
  • buildExpression(_ expression: Expression) -> Component
  • buildFinalResult(_ component: Component) -> FinalResult

While RegistrationBuilder does technically satisfy these requirements, it does not reference Component or FinalResult directly. If the type aliases are changed, the functions will no longer match.

Feature Request

The static methods of RegistrationBuilder should be updated to reference Component and/or FinalResult as applicable, rather than [Registration]. Additionally, the last overload of buildExpression(_:) (where S.Element == Registration) should be changed to return .init(expression) or return Component(expression), rather than referencing Array explicitly.

In line with these changes, perhaps the method signature of Factory.register(builder:) should be updated as well, to register(@RegistrationBuilder builder: () -> RegistrationBuilder.FinalResult).

Value

This change would put RegistrationBuilder more closely in line with the documentation for result builders, and reduce the amount of work necessary in the future should the types be changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions