Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix typo in receivers-flatmap.md #227

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/learn/design/receivers-flatmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fun getUserName(id: UserId, k: Continuation<String?>) =
getUserById(id) { user -> user?.let { k.resume(it.name) } }
```

At a conceptual level, you can think of `Continuation<A>` as simply a function `(A) -> Unit`. This means the caller can change how the function "returns," but changing the continuation passed as parameter `k`.
At a conceptual level, you can think of `Continuation<A>` as simply a function `(A) -> Unit`. This means the caller can change how the function "returns," by changing the continuation passed as parameter `k`.

The second feature in the Kotlin language required for the proposed style is [context receivers](https://github.com/Kotlin/KEEP/blob/master/proposals/context-receivers.md), which were introduced in version 1.6.20. For an in-depth discussion of this new feature, you can check this [talk](https://www.youtube.com/watch?v=2oiRCYnqhDs) or the corresponding [slides](https://serranofp.com/kotlin-xl-ctx/slides). Very briefly, context receivers can be thought of as _implicit_ parameters, or as a sort of built-in dependency injection. Let's say we define an interface for our user repository,

Expand Down