pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.22k stars 1.42k forks source link

Add ability to send actions / return effects using `UITransaction` #3289

Closed juliensagot closed 3 weeks ago

juliensagot commented 3 weeks ago

Adds methods to send actions and return effects using UITransaction:

return .run { send in
   await send(.buttonTapped, uiKitAnimation: .easeInOut)
}
return .run { send in
   await send(.buttonTapped)
}
.uiKitAnimation(.easeInOut)
return .run { send in
  await send(.buttonTapped, transaction: UITransaction(animation: .easeInOut))
}
var transaction = UITransaction()
transaction.uiKit.disablesAnimations = true

return .run { send in
  await send(.buttonTapped)
}
.transaction(transaction)
store.send(.buttonTapped, uiKitAnimation: .easeInOut)
store.send(.buttonTapped, transaction: UITransaction())

// ViewActionSending
send(.buttonTapped, uiKitAnimation: .easeInOut)
send(.buttonTapped, transaction: UITransaction())
juliensagot commented 3 weeks ago

@stephencelis That definitely makes sense! I hadn’t thought about creating an external package, but I think it’s a good idea. The more platform-agnostic TCA is, the better.