Better Programming

Advice for programmers.

Follow publication

Member-only story

How to Convert Your iOS Network Layer to Work With Combine or Async/await

Riccardo Cipolleschi
Better Programming
Published in
8 min readNov 25, 2021
Photo by Luana Azevedo on Unsplash

This year, Swift introduced the new async and await keyword. With them, we now have three ways to perform network operations:

  • By using the old callbacks model
  • By using Combine
  • By using async-await

In some cases, we make a decision early on one technology and we try to use it in all the modules of our app: if we start with Combine, for example, we may want to use Combine everywhere.

This approach has the clear upside of consistency: we don’t have to think about how to implement something and people joining the project won’t be surprised with multiple technologies when exploring the codebase.

The cost of consistency is flexibility. We would like to use the best tool for each situation. We could have modules that require us to use Combine for streams of events and others that could work with a callback for one-shot operations.

In today’s article, we explore how to convert a network layer from one technology to another. The network layer is just an example: whenever you need to transform an API from a technology to another, we can tap into these techniques.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Riccardo Cipolleschi
Riccardo Cipolleschi

Written by Riccardo Cipolleschi

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.

Write a response