Skip to content

Commit f847e27

Browse files
committed
Clarify docs for UIKit ifLet function (#497)
* Clarify docs for UIKit * Add clarification to override also
1 parent 90b15ee commit f847e27

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/ComposableArchitecture/UIKit/IfLetUIKit.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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`
@@ -33,9 +36,10 @@ extension Store {
3336
///
3437
/// - Parameters:
3538
/// - 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+
3943
/// - Returns: A cancellable associated with the underlying subscription.
4044
@discardableResult
4145
public func ifLet<Wrapped>(
@@ -72,7 +76,7 @@ extension Store {
7276
/// case.
7377
///
7478
/// - 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`.
7680
/// - Returns: A cancellable associated with the underlying subscription.
7781
@discardableResult
7882
public func ifLet<Wrapped>(

0 commit comments

Comments
 (0)