As a seasoned software architect with extensive experience, I founded Side Effect to provide top-notch architectural services to companies seeking mobile development expertise. Throughout my career working in both small and large businesses, I have faced various challenges. In this blog, I share some of my experiences and lessons learned. I hope you find it enjoyable to read.
When developing an iOS application, it is a common need to handle the frequency at which information is processed. For example, when making changes to a search field, we might want to request a remote API for each update. However, sending too many requests in quick succession can cause the server to become overloaded. To avoid this issue, it is important to pace the requests in order to prevent overloading the server. One solution to this problem is to use reactive programming and apply a Debounce operator to a stream of user inputs. However, if you don't want to use reactive programming, async sequences, or third-party libraries, you can explore a solution using pure Swift concurrency. In this article, we will look at how to use this approach to manage the frequency of information processing in an iOS application.
Swift 5.5 introduced structured concurrency, and with it came AsyncSequence, a new way to provide a flow of values over time. Wait, what? Isn't this what Combine is all about? From Apple, "The Combine framework provides a declarative Swift API for processing values over time". Are these technologies similar? Interchangeable? Well, sort of! In this article we will explore the differences and similarities between them and we will go over a repo that brings Combine-like operators to AsyncSequence.
Error is a base type in Swift that aims to represent an issue happening in the application flow; thus, it is very common to use it as an existential type that will cross the application layers. With Error being a protocol, we can implement our own custom errors making them Equatable if needed. In doing so we might have to leak implementation details across the application. This article explores a way to make an error conform to Equatable without compromising its abstraction.