Created
May 29, 2023 19:27
-
-
Save satanworker/6b45268343a1411890df2a8c2f8faa1a to your computer and use it in GitHub Desktop.
`flatMap` на вход приходит (String) и на выход `Effect(result)`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testAsyncEffect() -> Effect<Int, MainError> { | |
Effect<String, MainError>.future { callback in | |
DispatchQueue.global().async { | |
sleep(5) | |
callback(.success("All good")) | |
} | |
} | |
.flatMap { value -> Effect<Int, MainError> in | |
Effect.result { | |
.success(2) | |
} | |
} | |
.eraseToEffect() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment