@@ -4,6 +4,9 @@ extension Store {
44 /// Subscribes to updates when a store containing optional state goes from `nil` to non-`nil` or
55 /// non-`nil` to `nil`.
66 ///
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+ ///
710 /// This is useful for handling navigation in UIKit. The state for a screen that you want to
811 /// navigate to can be held as an optional value in the parent, and when that value switches
912 /// from `nil` to non-`nil` you want to trigger a navigation and hand the detail view a `Store`
@@ -35,9 +38,10 @@ extension Store {
3538 ///
3639 /// - Parameters:
3740 /// - unwrap: A function that is called with a store of non-optional state whenever the store's
38- /// optional state goes from `nil` to non-`nil`.
39- /// - else: A function that is called whenever the store's optional state goes from non-`nil` to
40- /// `nil`.
41+ /// optional state is initially non-`nil` or goes from `nil` to non-`nil`.
42+ /// - else: A function that is called whenever the store's optional state is initially `nil` or
43+ /// goes from non-`nil` to `nil`.
44+
4145 /// - Returns: A cancellable associated with the underlying subscription.
4246 public func ifLet< Wrapped> (
4347 then unwrap: @escaping ( Store < Wrapped , Action > ) -> Void ,
@@ -76,7 +80,7 @@ extension Store {
7680 /// case.
7781 ///
7882 /// - Parameter unwrap: A function that is called with a store of non-optional state whenever the
79- /// store's optional state goes from `nil` to non-`nil`.
83+ /// store's optional state is initially non-`nil` or goes from `nil` to non-`nil`.
8084 /// - Returns: A cancellable associated with the underlying subscription.
8185 public func ifLet< Wrapped> (
8286 then unwrap: @escaping ( Store < Wrapped , Action > ) -> Void
0 commit comments