profile
viewpoint
Petr Sima pteasima Prague, Czech Republic iOS developer and mentor

startedfermoya/CustomNavigations

started time in 2 days

startedspring-media/Carlos

started time in 11 days

startednarlei/CardScanner

started time in 15 days

startedonevcat/Kingfisher

started time in 15 days

Pull request review commentpointfreeco/swift-composable-architecture

Breakpoint instead of assert in optional/forEach

 public struct Reducer<State, Action, Environment> {   ///       }   ///     )   ///-  /// Take care when combining optional reducers into parent domains, as order matters. Always-  /// combine optional reducers _before_ parent reducers that can `nil` out the associated optional-  /// state.+  /// Take care when combining optional reducers into parent domains. An optional reducer cannot+  /// process actions in its domain when its state is `nil`. If a child action is sent to an+  /// optional reducer when child state is `nil`, it is generally considered a logic error. There+  /// are a few ways in which these errors can sneak into a code base:+  ///+  ///   * A parent reducer sets child state to `nil` when processing a child action and runs+  ///     _before_ the child reducer:+  ///+  ///         let parentReducer = Reducer<ParentState, ParentAction, ParentEnvironment>.combine(+  ///           // When combining reducers, the parent reducer runs first+  ///           Reducer { state, action, environment in+  ///             switch action {+  ///             case .child(.didDisappear):+  ///               // And `nil`s out child state when processing a child action+  ///               state.child = nil+  ///               return .none+  ///             ...+  ///             }+  ///           },+  ///           // Before the child reducer runs+  ///           childReducer.optional().pullback(...)+  ///         )+  ///+  ///         let childReducer = Reducer<+  ///           ChildState, ChildAction, ChildEnvironment+  ///         > { state, action environment in+  ///           case .didDisappear:+  ///             // This action is never received here because child state is `nil` in the parent+  ///           ...+  ///         }+  ///+  ///     To ensure that a child reducer can process any action that a parent may use to `nil` out+  ///     its state, combine it _before_ the parent:+  ///+  ///         let parentReducer = Reducer<ParentState, ParentAction, ParentEnvironment>.combine(+  ///           // The child runs first+  ///           childReducer.optional().pullback(...),+  ///           // The parent runs after+  ///           Reducer { state, action, environment in+  ///             ...+  ///           }+  ///         )+  ///+  ///   * A child effect feeds a child action back into the store when child state is `nil`:+  ///+  ///         let childReducer = Reducer<+  ///           ChildState, ChildAction, ChildEnvironment+  ///         > { state, action environment in+  ///           switch action {+  ///           case .onAppear:+  ///             // An effect may want to feed its result back to the child domain in an action+  ///             return environment.apiClient+  ///               .request()+  ///               .map(ChildAction.response)+  ///+  ///           case let .response(response):+  ///             // But the child cannot process this action if its state is `nil` in the parent+  ///           ...+  ///           }+  ///         }+  ///+  ///     It is perfectly reasonable to ignore the result of an effect when child state is `nil`,+  ///     for example one-off effects that you don't want to cancel. However, many long-living+  ///     effects _should_ be explicitly canceled when tearing down a child domain:+  ///+  ///         let childReducer = Reducer<+  ///           ChildState, ChildAction, ChildEnvironment+  ///         > { state, action environment in+  ///           struct MotionId: Hashable {}+  ///+  ///           switch action {+  ///           case .onAppear:+  ///             // Mark long-living effects that shouldn't outlive their domain cancellable+  ///             return environment.motionClient+  ///               .start()+  ///               .map(ChildAction.motion)+  ///               .cancellable(id: MotionId())+  ///+  ///           case .onDisappear:+  ///             // And explicitly cancel them when the domain is torn down+  ///             return .cancel(id: MotionId())+  ///           ...+  ///           }+  ///         }+  ///+  ///   * A view store sends a child action when child state is `nil`:+  ///+  ///         WithViewStore(self.parentStore) { parentViewStore in+  ///           // If child state is `nil`, it cannot process this action.+  ///           Button("Child Action") { parentViewStore.send(.child(.action)) }+  ///           ...+  ///         }+  ///+  ///     Use `Store.scope` with`IfLetStore` or `Store.ifLet` to ensure that views can only send+  ///     child actions when the child domain is non-`nil`.+  ///+  ///         IfLetStore(+  ///           self.parentStore.scope(state: { $0.child }, action: { .child($0) }+  ///         ) { childStore in+  ///           // This destination only appears when child state is non-`nil`+  ///           WithViewStore(childStore) { childViewStore in+  ///             // So this action can only be sent when child state is non-`nil`+  ///             Button("Child Action") { childViewStore.send(.action) }+  ///           }+  ///           ...+  ///         }   ///   /// - See also: `IfLetStore`, a SwiftUI helper for transforming a store on optional state into a   ///   store on non-optional state.   /// - See also: `Store.ifLet`, a UIKit helper for doing imperative work with a store on optional   ///   state.-  public func optional(_ file: StaticString = #file, _ line: UInt = #line) -> Reducer<+  ///+  /// - Parameter breakpointOnNil: Raises `SIGTRAP` signal when an action is sent to the reducer+  ///   but state is `nil`. This is generally considered a logic error, as a child reducer cannot+  ///   process a child action for unavailable child state.+  /// - Returns: A reducer that works on optional state.+  public func optional(+    breakpointOnNil: Bool = true,

As always, thanks for the great work 👏 .

Would you consider a setup where we take a canIgnoreAction: (Action) -> Bool = { _ in false } parameter? Id love to retain the strict behavior for most actions and explicitly list those that can come in post mortem.

stephencelis

comment created time in 16 days

PullRequestReviewEvent

startedapple/swift-algorithms

started time in 19 days

issue closedLeslieLee23/FireScoreboard

contact info

closed time in 21 days

pteasima

issue openedLeslieLee23/FireScoreboard

contact info

Hey Leslie, Petr from codementor here. This the easiest I could reach you, hope you dont mind this. My email address is ptea.sima@gmail.com

created time in 21 days

startedapple/swift-atomics

started time in 24 days

starteddevxoul/Toaster

started time in a month

startedsoto-project/soto

started time in a month

startedDevUtilsApp/DevUtils-app

started time in a month

startedchaubss/Hidden-Widgets

started time in a month

startedapple/swift-system

started time in a month

startedImpedimenta/Suitcase

started time in a month

startedRadarCOVID/radar-covid-ios

started time in 2 months

startedmongodb/mongo-swift-driver

started time in 2 months

startedjordansinger/text-editor-macos-sample

started time in 2 months

startedKotlin/kmm-sample

started time in 2 months

startedRevenueCat/purchases-ios

started time in 2 months

startedapple/swift-cluster-membership

started time in 2 months

starteddempseyatgithub/UnofficialSandwiches

started time in 2 months

starteddasautoooo/Parma

started time in 2 months

startedShubham0812/SwiftUI-Animations

started time in 2 months

startedsimonwagner/mergepbx

started time in 2 months

startedItaybre/CameraController

started time in 3 months

startedDimillian/RedditOS

started time in 3 months

startedhome-assistant/iOS

started time in 3 months

push eventpteasima/BetterEnvironment

Petr Sima

commit sha bb620dcdfed6187edab9286763ecf430400f26ed

simplified by replace Tagged with HashableType

view details

push time in 3 months

startednoppefoxwolf/RefreshUI

started time in 3 months

startedAmeddahAchraf/Food-Delivery-SwiftUI

started time in 3 months

more