What is “reference type” in Swift?

Introduction In Swift, classes, closures, and actors all reference types. ‘Reference type’ is instance that shares a single copy of data. Assigning a reference type to a constant or variable, or passing it into a function or method, it is always a reference to a shared instance that is assigned or passed in. Example You can pass your property value by sharing the same address in memory. // Reference type example class Storage { var data = “data-example” } var storage = Storage() print("\(storage.data)") // prints "data-example" print("storage address:", Unmanaged.passUnretained(storage).toOpaque()) var copiedStorage = storage copiedStorage.data = “new-data” print("\(storage.data), \(copiedStorage.data)") // prints "new-data, new-data" print("copiedStorage address:", Unmanaged.passUnretained(copiedStorage).toOpaque()) ...

December 3, 2023 · 1 min · Dmytro Chumakov

Let’s talk about Composable Architecture

Introduction The Composable Architecture (TCA) uses a unidirectional data flow (UDF). UDF is a design pattern where data and events move consistently and predictably. In UDF, data can only be transferred to other application parts in one way. In TCA, the only way to mutate the state is by sending actions to a runtime store. The runtime store holds the entire app’s business logic and mutates the state inside. UDF can reduce data inconsistencies because of the single source of truth for the application. ...

August 11, 2023 · 1 min · Dmytro Chumakov