This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func listProperties(of subject: Any, maxDepth: Int? = nil) { | |
func listProperties(of subject: Any, maxDepth: Int?, indentationLevel: Int) { | |
if let maxDepth, maxDepth == 0 { | |
return | |
} else { | |
let mirror = Mirror(reflecting: subject) | |
let indentation = String(repeating: "\t", count: indentationLevel) | |
for case (let label, let value) in mirror.children { | |
print("\(indentation)▶︎ \(label ?? "<unknown label>"): \(type(of: value)) = \(value)") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Implementation | |
@dynamicMemberLookup | |
public class ThemeManager<Theme> { | |
public var theme: Theme { | |
didSet { | |
for (_, handler) in observations { | |
handler(theme) | |
} |