Skip to content

Limitation of the "when" function to 5 elements #1268

Closed

Description

@vicajilau

I am using PromiseKit version 6.15.3 and the when function is limited to 5 items. I have added a sixth element modifying the library locally. I don't know if a 6-parameter when function is a good practice and if it is considered good, I could perform a PR with these changes.

image

Activity

  1. mxcl commented on Sep 23, 2021

    @mxcl
    Owner

    Without Swift variadic generics this is necessary. You can add the extension locally to your project, we don’t want to keep adding more of these. Thanks though.

  2. mxcl commented on Sep 23, 2021

    @mxcl
    Owner

    As a general solution, we suggest use of when([Promise<T>]) in our documentation, where you void each promise first and get the values out the other end.

  3. Nikoloutsos commented on Feb 5, 2026

    @Nikoloutsos

    Although this is an old post writing this for future readers.

    @vicajilau from swift 5.9 and onwards we can use variadic generics like this. Allowing from 0..* elements.

    public func when<each U: Thenable>(fulfilled: repeat each U) -> Promise<(repeat (each U).T)> {
        var voidPromises: [Promise<Void>] = []
        repeat voidPromises.append((each fulfilled).asVoid())
        return _when(voidPromises).map(on: nil) { (repeat (each fulfilled).value!) }
    }
  4. RomanPodymov commented on Feb 14, 2026

    @RomanPodymov
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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