Combine: Handle nil values with compactMap

In some case, you could have your publisher emit some nullable value and don’t want it.

The operator compactMap publish all non-nil element. It can be useful if you don’t want to handle unwrapping in your sink or other combine operators.

You can find the playground here

More informations on Apple documentation

Android & iOS, quality in software is 𝛼&ɷ

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store