Skip to content

Commit

Permalink
chore: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-pavlov committed Oct 11, 2023
1 parent 7b6107b commit fa26f71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docs/topics/multiplatform/multiplatform-connect-to-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ your Kotlin Multiplatform module. Do **not** include any implementation code.
expect fun randomUUID(): String
```

In each platform-specific source set (iOS and Android), provide the actual implementation for the
function `randomUUID()` expected in the common module. Use the `actual` keyword to mark these actual implementations.
In each platform-specific source set (iOS and Android), provide the actual implementation for the `randomUUID()`
function expected in the common module. Use the `actual` keyword to mark these actual implementations.

![(Generating UUID with expected and actual declarations).](expect-generate-uuid.png){width=500}

Expand Down Expand Up @@ -150,9 +150,9 @@ class IOSPlatform : Platform
actual fun platform() = IOSPlatform()
```

WHen you call `platform()` in the common code, it can work with an object of the `Platform` type. When you run this common
code on Android, the `platform()` call returns an instance of the `AndroidPlatform` class. When you run it on
iOS, `platform()` returns an instance of the `IOSPlatform` class.
When you call the `platform()` function in the common code, it can work with an object of the `Platform` type.
When you run this common code on Android, the `platform()` call returns an instance of the `AndroidPlatform` class.
When you run it on iOS, `platform()` returns an instance of the `IOSPlatform` class.

### Different entry points

Expand Down Expand Up @@ -219,7 +219,7 @@ A modern application typically uses a dependency injection (DI) framework to cre
DI framework allows injecting dependencies into components based on the current environment.

Any DI framework that supports Kotlin Multiplatform can help you inject different dependencies for different platforms.
We don't recommend a specific framework. Use the one that bests suits your needs.
We don't recommend a specific framework. Use the one that best suits your needs.

For example, [Koin](https://insert-koin.io/) is a dependency injection framework that supports Kotlin Multiplatform:

Expand Down
16 changes: 8 additions & 8 deletions docs/topics/multiplatform/multiplatform-expect-actual.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{type="warning"}

Expected and actual declarations allow you to access platform-specific APIs from the Kotlin Multiplatform modules.
Then, in the common code, you can then provide platform-agnostic APIs.
Then, in the common code, you can provide platform-agnostic APIs.

> This article describes the language mechanism of expected and actual declarations. For general recommendations on
> different ways to use platform specifics, see [Use platform-specific APIs](multiplatform-connect-to-apis.md).
Expand All @@ -25,7 +25,7 @@ To define expected and actual declarations, follow these rules:
3. In each platform-specific source set, declare the same construct in the same package and mark it with the `actual`
keyword. It's your _actual declaration_. Typically, it contains an implementation using platform-specific libraries.

During compilation for a specific target, the compiler tries to match each actual declaration it finds with the
During compilation for a specific target, the compiler tries to match each _actual_ declaration it finds with the
corresponding _expected_ declaration in common code. The compiler ensures that:

* Every expected declaration in the common source set has a matching actual declaration in every platform-specific
Expand All @@ -46,17 +46,17 @@ corresponding platforms.

The IDE assists with common issues, like:

* When declarations are missing
* The expected declaration contains implementation
* The signatures of declarations do not match
* Missing declarations
* The expected declaration contains an implementation
* The signatures of declarations don't match
* Declarations are in different packages

You can also use the IDE to navigate from expected to actual declarations. Select the gutter icon to view actual
declarations or use [shortcuts](https://www.jetbrains.com/help/idea/navigating-through-the-source-code.html#go_to_implementation).

![IDE navigation from expected to actual declarations](expect-actual-gutter.png){width=500}

## Different approaches for using the expected and actual declarations
## Different approaches for using expected and actual declarations

Let's explore the different options of using the expected/actual mechanism to solve the problem of accessing
platform APIs while still providing a way to work with them in the common code.
Expand Down Expand Up @@ -112,7 +112,7 @@ and implemented differently in platform source sets:

Here, platform functions return platform-specific `Identity` instances.

> Starting with Kotlin version 1.9.0, using `getlogin()` and `getpid()` requires the `@OptIn` annotation.
> Starting with Kotlin version 1.9.0, using `getlogin()` and `getpid()` functions requires the `@OptIn` annotation.
>
{type="note"}

Expand Down Expand Up @@ -251,7 +251,7 @@ This means that the only case when expected and actual declarations are needed i
framework. See [Use platform-specific APIs](multiplatform-connect-to-apis.md#dependency-injection-framework) for examples.
With this approach, you can adopt Kotlin Multiplatform simply by using interfaces and factory functions. If you already
use the DI framework to manage dependencies in your project, we recommended that you use the same approach for managing
use the DI framework to manage dependencies in your project, we recommend that you use the same approach for managing
platform dependencies.
### Expected and actual classes
Expand Down

0 comments on commit fa26f71

Please sign in to comment.