Use the map operator in Combine to transform values from one type to another.

import Combine

(1...3).publisher
    .map { "\($0)" }
    .sink { print($0) }

In the above code:

  1. The publisher emits values from 1 to 3.
  2. The map operator transforms the emitted value to a string representation.
  3. The sink subscriber prints the transformed values.

The output of the above code will be:

1
2
3