Documenting Combine

« Functional Chapter 2

Higher-Order Functions »

Last week I gave a talk at the Philly ETE conference outlining what changes in your architecture when you move to SwiftUI and Combine.

It's a simple example that will probably become part of my book on Combine (which is in line after I'm done with my Functional Programming Kickstart and possibly a book on baking bread).

At the end, the user can play Rock Paper Scissors against the machine and I wasn't getting the result I wanted.

I ended up zipping the results together and things worked as they should.

So I posted the video on a new teachable site I'm playing with to possibly launch courses and a subscription. Unfortunately, you can't just play the example - I think you have to log in. But if you'd like, I've posted it for free at SwiftUI and Combine Changes Everything.

I'm experimenting with that style for my videos - though the teaching videos will be short. They will be 3-6 minutes where this conference video is 32 minutes.

Anyway, after posting it, I woke up worried that I'd taught something wrong so I went to read up about it and check. I have two go-to resources for looking up what an operator or publisher does.

Joe Heck's Using Combine is first rate. You should check it out and if you're able, please buy a copy to support Joe's efforts. You can read it for free online but I've gotten way more than my money's worth from his offering.

And then, of course, there's Apple's documentation.

So I looked there too as I always do.

But here's the thing. Now there's more there there

Start with their Publisher documentation.

Scroll down and all of the operators are grouped nicely in categories. Tap zip().

Hey wait a minute. There's a "Discussion" section with code examples.

Back button.

Scroll. Scroll. Scroll.

Tap map().

It has a Discussion section with code examples as well.

Wait, so does tryMap() ending with the advice of when I just want to use map().

Thank you Apple.

This makes me so happy. Granted, we should have had this documentation in June 2019 - but this is the documentation we've been waiting for.

I'd love to see a Combine Programming Guide as well but this is a great step.