@@ -4,6 +4,9 @@ extension Store {
4
4
/// Subscribes to updates when a store containing optional state goes from `nil` to non-`nil` or
5
5
/// non-`nil` to `nil`.
6
6
///
7
+ /// **NOTE:** one of the `unwrap` or `else` closures is always called based on the *initial* state of the
8
+ /// optional state (`nil` or non-`nil`), in addition to subsequent changes of `nil` / non-`nil`.
9
+ ///
7
10
/// This is useful for handling navigation in UIKit. The state for a screen that you want to
8
11
/// navigate to can be held as an optional value in the parent, and when that value switches
9
12
/// from `nil` to non-`nil` you want to trigger a navigation and hand the detail view a `Store`
@@ -33,9 +36,10 @@ extension Store {
33
36
///
34
37
/// - Parameters:
35
38
/// - unwrap: A function that is called with a store of non-optional state whenever the store's
36
- /// optional state goes from `nil` to non-`nil`.
37
- /// - else: A function that is called whenever the store's optional state goes from non-`nil` to
38
- /// `nil`.
39
+ /// optional state is initially non-`nil` or goes from `nil` to non-`nil`.
40
+ /// - else: A function that is called whenever the store's optional state is initially `nil` or
41
+ /// goes from non-`nil` to `nil`.
42
+
39
43
/// - Returns: A cancellable associated with the underlying subscription.
40
44
@discardableResult
41
45
public func ifLet< Wrapped> (
@@ -72,7 +76,7 @@ extension Store {
72
76
/// case.
73
77
///
74
78
/// - Parameter unwrap: A function that is called with a store of non-optional state whenever the
75
- /// store's optional state goes from `nil` to non-`nil`.
79
+ /// store's optional state is initially non-`nil` or goes from `nil` to non-`nil`.
76
80
/// - Returns: A cancellable associated with the underlying subscription.
77
81
@discardableResult
78
82
public func ifLet< Wrapped> (
0 commit comments