Skip to content

support resolving multiple T into []T #8

@zzzz465

Description

@zzzz465

Is your feature request related to a problem? Please describe.

when wiring multiple same types, currently I'm forced to create a new type from slice type and write a Provider function manually, like this

type Handlers []types.Handlers

func HandlersProvider() Handlers {
  return []types.Handlers {
    handler.NewHandlerA,
    handler.NewHandlerB,
   ...
}

Describe the solution you'd like

wire.Slice(
  T,
  providers...
)

for example, like this

// this provides multiple T into single T, also this can be defined multiple times, everything will be joined to single type
wire.Slice(
  []types.EventHandler,
  handler.NewHandlerA,
  handler.NewHandlerB,
  handler.NewHandlerC,
  ... // keep going
)

Describe alternatives you've considered

Additional context

I implemented Proof of Concept in my forked branch. see below:
https://github.com/zzzz465/wire/tree/feat/wire-slice

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions