Skip to content

Tiny observation framework designed for UIKit-based apps and built with Swift macros. It automatically handles the deallocation of observations and supports iOS 12 and newer.

Notifications You must be signed in to change notification settings

simonbs/SBSObservation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SBSObservation

Important

This framework is an experimental project that reimplements and backports parts of Apple’s Observation framework to iOS 12, with similar internals and a more ergonomic API.

The source code is provided for inspirational purposes and as-is, without any guarantees of correctness, stability, or future maintenance. Use it at your own risk.

Tiny observation framework designed for UIKit-based apps and built with Swift macros. It automatically handles the deallocation of observations and supports iOS 12 and newer.

@SBSObservable
final class Car {
    var speed: Int = 0
}

@SBSObserver
final class MainViewController: UIViewController {
    private let car = Car()

    override func viewDidLoad() {
        super.viewDidLoad()
        observe(\.speed, of: car) { [unowned self] _, newValue in
            self.contentView.speedLabel.text = "\(newValue) mph"
        }
    }
}

About

Tiny observation framework designed for UIKit-based apps and built with Swift macros. It automatically handles the deallocation of observations and supports iOS 12 and newer.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Languages