• Combine: key operators to know

    Combine contains a long list of operators which are great to know. While all of them are useful and can help you, I am going to focus on 4 operators which I see pretty much in any combine chain in a big project. Prepend A publisher that prefixes a sequence of elements prior to this…

  • Combine basics: types of Publishers

    Just A publisher that emits an output to each subscriber just once and then finishes. Generic only over the output since can not fail. The output is: The publisher emits one value to each subscriber and then finishes with no error. Empty A publisher that never publishes any values and optionally finishes immediately. It can…

  • Property Wrappers

    What is a property wrapper? We can think of property wrappers as a way to decorate variables and function parameters. We can use it to run additional code every time a variable is accessed or set. One of the most common uses is to reuse repetitive code. We can create a property wrapper using a…

  • KeyPath

    We can use key paths to have a reference to a property from an object. For example, in this simple case, we can pass to a method an object and a reference to a property from that object. We have different types of key path references. KeyPath is a read-only reference, but we can pass…

  • Custom operators

    We can create our custom operators and combine them. It is not a common practice but can be useful in some cases. Let’s start by creating an operator similar to the UNIX pipeline |: echo “Hello” | wc -l This operator will redirect the output from the left, as an input for the right closure:…