Skip to content

Commit 303cbf0

Browse files
send notification when the current theme changes
1 parent 3d7951f commit 303cbf0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Sources/ComponentsKit/Theme/Theme.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@ public struct Theme: Initializable, Updatable, Equatable {
1717
public init() {}
1818
}
1919

20-
// MARK: - Theme + Shared
20+
// MARK: - Theme + Current
2121

2222
extension Theme {
23+
/// A notification that is triggered when a theme changes.
24+
public static let didChangeThemeNotification = Notification.Name("didChangeThemeNotification")
25+
2326
/// A current instance of `Theme` for global use.
24-
public static var current: Self = .init()
27+
///
28+
/// Triggers `Theme.didChangeThemeNotification` notification when the value changes.
29+
public static var current = Self() {
30+
didSet {
31+
NotificationCenter.default.post(
32+
name: Self.didChangeThemeNotification,
33+
object: nil
34+
)
35+
}
36+
}
2537
}

0 commit comments

Comments
 (0)