SRGSSR / srgdataprovider-apple

A library to retrieve SRG SSR unified metadata
MIT License
0 stars 1 forks source link

Avoid type erasure need in accumulation publishers #39

Closed defagos closed 1 year ago

defagos commented 1 year ago

Publishers.AccumulateLatestMany currently takes AnyPublishers as parameters but this is suboptimal, as this requires explicit type erase at the call site:

Publishers.AccumulateLatestMany(
    Just(1).eraseToAnyPublisher(),
    Just(2).eraseToAnyPublisher(),
    Just(3).eraseToAnyPublisher()
}

We would prefer to write the same code as follows:

Publishers.AccumulateLatestMany(
    Just(1),
    Just(2),
    Just(3)
}

since publishers only have to agree on their output and error types. Type erasure is really not required here.

defagos commented 1 year ago

We only have to update the prototype to better use generic constraints. Note that Play SRG code that currently uses Publishers.AccumulateLatestMany already works on type-erased publishers (returned by methods), so there is no code change to be made in the Play SRG codebase.