map vs compactMap vs flatMap
First We see the code
CompactMap filter ‘nil’
And you use .publish. it will send the value one by one.
But you want replace “nil” to some value. Try this one.
FlatMap is more
ps. flatMap in Combine, the error type of the new publisher must match that of the source publisher.
Next one for more flatMap ~~!