Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save satanworker/92b0664631b4914372fbd11d039a923e to your computer and use it in GitHub Desktop.
Save satanworker/92b0664631b4914372fbd11d039a923e to your computer and use it in GitHub Desktop.
`.eraseToEffect` - когда нужно схлопнуть несколько операторов в один эффект, чтобы компилятор не отъехал
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