Swift Combine: Transforming Operators, The Most Basic Concept
Transforming Operators exist in all reactive frameworks. Even higher order function does the same thing. So, it’s important to understand the concept! Because you can apply this concept beyond your application. I would say software-wide
Transforming Operators
Before diving into the implementation details of transformation operators, it’s a good idea to understand what exactly what transformation operators are.
Let’s say that you have a sequence of numbers, but it can be anything, it doesn’t have to be a sequence of numbers. And you pass that from a transformation operator.
So, these operators come in many different variety of shapes and forms.
Let’s say that we have an array of numbers or a sequence of numbers and you pass it through this particular transformation operator.
Then using the transformation operator, you can actually change the appearance or transform that sequence into a completely different sequence.
As you can see right now, you have taken in an array or a sequence to one, two, three.
So, the whole point of transformation operator is to take in a sequence and then transform it into a completely different sequence.
Transformation Operators
- scan
- map
- map keypath
- collect
- flatMap
- trypMap
- replaceNil
- replaceEmpty
There are obviously a lot of different transformational operators that you can use, which will fit your needs, but this is a list of only a few of them.
Conclusion
- you can actually change the appearance or transform that sequence into a completely different sequence.