Skip to content

Instantly share code, notes, and snippets.

View KoCMoHaBTa's full-sized avatar
🚀
🌔

Milen Halachev KoCMoHaBTa

🚀
🌔
  • Plovdiv, Bulgaria
View GitHub Profile
@KoCMoHaBTa
KoCMoHaBTa / CustomStateObject.swift
Created December 9, 2021 12:40 — forked from DevAndArtist/CustomStateObject.swift
Custom `StateObject` which should be backwards compatible with iOS 13.
import SwiftUI
import Combine
/// The idea is to use State to create a storage object which will be
/// cached and restored by the framework. Then during the update phase we
/// re-inject the object into a nested ObservableObject and subscribe to the
/// ObjectType’s objectWillChange to forward to the _MessageForwarder’s
/// objectWillChange which is already subscribed by the framework as it’s an
/// inner dynamic property of our custom PW which is also a dynamic property.
@propertyWrapper