Describe the bug 🐛
Let's suppose using sdk's async block function(closure) methods
class OneWayReducer: Reducer {
enum Action {
case setText(String)
case loadAsync
case setTexts([String])
}
struct State: Equatable {
var text: String = ""
var texts: [String] = []
}
private let sdk = SDK()
func reduce(state: inout State, action: Action) -> AnyEffect<Action> {
switch action {
case let .setText(value):
state.text = value
return .none
case .loadAsync:
return loadMore(state)
case let .setTexts(value):
state.texts = value
print("❌ 3 reach x")
return .none
}
}
func loadMore(
_ state: State
) -> AnyEffect<Action> {
.sequence { [sdk] send in
sdk.asyncCompletion { values, error in
if let values {
print("✔️ 2 inLoadMore")
send(.setTexts(values))
}
}
}
}
}
public typealias AsyncHandler = ((_ values: [String]?, _ error: NSError?) -> Void)
class SDK: NSObject {
func asyncCompletion(completionHandler: @escaping AsyncHandler) {
DispatchQueue.global().asyncAfter(deadline: .now() + 1) {
print("✔️ 1 hello")
completionHandler(["hello"], nil)
}
}
}
// prints after store.send(.loadAsunc)
// ✔️ 1 hello
// ✔️ 2 inLoadMore
on above code, print("❌ 3 reach x") must be excuted but it does not.
Since Sequence finished it, it does not reach
Suggestion 🖐️
Speaking of this, I suggest reverted this Stream Commit
to handle old async swift stuffs such as closures or delegates
Environments ⚙️
- Mac OS: 14.1
- Device or Simulator OS: iOS 17.2
- Xcode Version: 15.1
- Library Version: 2.2.1
Describe the bug 🐛
Let's suppose using sdk's async block function(closure) methods
on above code,
print("❌ 3 reach x")must be excuted but it does not.Since Sequence finished it, it does not reach
Suggestion 🖐️
Speaking of this, I suggest reverted this Stream Commit
to handle old async swift stuffs such as closures or delegates
Environments ⚙️