Skip to content

Instantly share code, notes, and snippets.

@marcoarment
marcoarment / OCObservableKeyPaths.swift
Last active January 18, 2024 06:01
A Combine publisher for `@Observable` key-paths
// I think this works and doesn't create circular references?
/*
Usage: Add OCObservableKeyPaths conformance to the observed type. Then, e.g.
audioPlayer
.publisher(forObservableKeyPaths: [ \.timestamp, \.duration ])
.sink {
// respond to change
}