Bahn-X / swift-composable-navigator

An open source library for building deep-linkable SwiftUI applications with composition, testing and ergonomics in mind
MIT License
581 stars 25 forks source link

Adds beforeBuild helper #7

Closed ohitsdaniel closed 3 years ago

ohitsdaniel commented 3 years ago

Swift complains about not being able to infer complex return types when actions are performed as part of PathBuilder build closures.

Example

PathBuilders.if { (screen: Screen) in 
   print("Hello")
   return PathBuilders.empty
}

fails to build, but

PathBuilders.if { (screen: Screen) in 
   return PathBuilders.empty
}

succeeds.

The beforeBuild helper allows you to perform actions (like sending actions into a ViewStore) everytime a path is built.

PathBuilders.if { (screen: Screen) in 
   return PathBuilders.empty.beforeBuild { print("Hello") }
}