Skip to content

Commit

Permalink
Merge pull request #1796 from pedrofsn/fix/pedrofsn/1795-proofreading…
Browse files Browse the repository at this point in the history
…-docs

[DOC][FIX-1795] - Proofreading docs
  • Loading branch information
arnaudgiuliani authored Feb 29, 2024
2 parents 581640c + c004609 commit 625cff2
Show file tree
Hide file tree
Showing 28 changed files with 63 additions and 65 deletions.
2 changes: 1 addition & 1 deletion docs/reference/koin-android/dsl-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Constructor DSL for Android

## New Constructor DSL (Since 3.2)

Koin now offer a new kind of DSL keyword that allow you to target a class constructor directly, and avoid to to have type your definition within a lambda expression.
Koin now offer a new kind of DSL keyword that allow you to target a class constructor directly, and avoid to have type your definition within a lambda expression.

Check the new [Constructor DSL](../koin-core/dsl-update.md#constructor-dsl-since-32) section for more details.

Expand Down
8 changes: 4 additions & 4 deletions docs/reference/koin-android/fragment-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ https://developer.android.com/jetpack/androidx/releases/fragment

## Fragment Factory

Since `2.1.0-alpha-3` version, has been introduce the `FragmentFactory`, a class dedicated to create instance of `Fragment` class:
Since `2.1.0-alpha-3` version, has been introduced the `FragmentFactory`, a class dedicated to create instance of `Fragment` class:

https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentFactory

Koin can bring a `KoinFragmentFactory` to help you inject your `Fragment` instances directly.

## Setup Fragment Factory

At start, in your KoinApplication declaration, use the `fragmentFactory()` keyword to setup a default `KoinFragmentFactory` instance:
At start, in your KoinApplication declaration, use the `fragmentFactory()` keyword to setting up a default `KoinFragmentFactory` instance:

```kotlin
startKoin {
Expand Down Expand Up @@ -49,7 +49,7 @@ val appModule = module {

## Get your Fragment

From your host `Activity` class, setup your fragment factory with `setupKoinFragmentFactory()`:
From your host `Activity` class, setting up your fragment factory with `setupKoinFragmentFactory()`:

```kotlin
class MyActivity : AppCompatActivity() {
Expand Down Expand Up @@ -95,7 +95,7 @@ val appModule = module {
}
```

and setup your Koin Fragment Factory with your scope: `setupKoinFragmentFactory(lifecycleScope)`
and setting up your Koin Fragment Factory with your scope: `setupKoinFragmentFactory(lifecycleScope)`

```kotlin
class MyActivity : AppCompatActivity() {
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/koin-android/get-instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Injecting in Android
---


Once you have declared some modules and you have started Koin, how can you retrieve your instances in your
Once you have declared some modules, and you have started Koin, how can you retrieve your instances in your
Android Activity Fragments or Services?

## Ready for Android Classes
Expand Down Expand Up @@ -48,12 +48,12 @@ override fun onCreate(savedInstanceState: Bundle?) {
```

:::info
if you class doesn't have extensions, just add KoinComponent interface If you need to `inject()` or `get()` an instance from another class.
if your class doesn't have extensions, just implement the `KoinComponent` interface in it to `inject()` or `get()` an instance from another class.
:::

## Using the Android Context in a Definition

Once your `Application` class you can use `androidContext` function:
Once your `Application` class configures Koin you can use the `androidContext` function to inject Android Context so that it can be resolved later when you need it in modules:

```kotlin
class MainApplication : Application() {
Expand All @@ -62,7 +62,7 @@ class MainApplication : Application() {
super.onCreate()

startKoin {
//inject Android context
// inject Android context
androidContext(this@MainApplication)
// ...
}
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/koin-android/modules-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ By using Koin, you describe definitions in modules. In this section we will see

## Using several modules

Components doesn't have to be necessarily in the same module. A module is a logical space to help you organize your definitions, and can depend on definitions from other
module. Definitions are lazy, and then are resolved only when a a component is requesting it.
Components don't have to be necessarily in the same module. A module is a logical space to help you organize your definitions, and can depend on definitions from another
module. Definitions are lazy, and they are resolved only when a component requests them.

Let's take an example, with linked components in separate modules:

Expand Down Expand Up @@ -124,7 +124,7 @@ Notice that all modules will be included only once: `dataModule`, `domainModule`

## Reducing Startup time with background module loading

You can now declared "lazy" Koin module, to avoid trigger any pre allocation of resources and load them in background with Koin start. This can help avoid to block Android starting process, by passing lazy modules to be loaded in background.
You can now declare "lazy" Koin module, to avoid trigger any pre allocation of resources and load them in background with Koin start. This can help avoid to block Android starting process, by passing lazy modules to be loaded in background.

- `lazyModule` - declare a Lazy Kotlin version of Koin Module
- `Module.includes` - allow to include lazy Modules
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/koin-android/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ abstract class ScopeActivity(
}
```

We need to use the `AndroidScopeComponent` interface and implement the `scope` property. This will setup the default scope used by your class.
We need to use the `AndroidScopeComponent` interface and implement the `scope` property. This will setting up the default scope used by your class.

### Android Scope API

Expand All @@ -132,7 +132,7 @@ class MyActivity() : AppCompatActivity(contentLayoutId), AndroidScopeComponent {
}
```

We can also setup a retained scope (backed by a ViewModel lifecycle) with the following:
We can also to setting up a retained scope (backed by a ViewModel lifecycle) with the following:

```kotlin
class MyActivity() : AppCompatActivity(contentLayoutId), AndroidScopeComponent {
Expand Down
14 changes: 6 additions & 8 deletions docs/reference/koin-android/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
title: Start Koin on Android
---

The `koin-android` project is dedicated to provide Koin powers to Android world. See the [Android setup](../../setup/v3.2#android) section for more details.
The `koin-android` project is dedicated to provide Koin powers to Android world. See the [Android setup](../../setup/koin#android) section for more details.

## From your Application class

From your `Application` class you can use the `startKoin` function and inject the Android context with `androidContext` as follow:
From your `Application` class you can use the `startKoin` function and inject the Android context with `androidContext` as follows:

```kotlin
class MainApplication : Application() {
Expand All @@ -22,13 +22,12 @@ class MainApplication : Application() {
// Load modules
modules(myAppModules)
}

}
}
```

:::info
You can also start Koin from anywhere if you don't ant to start it from your Application class.
You can also start Koin from anywhere if you don't want to start it from your Application class.
:::

If you need to start Koin from another Android class, you can use the `startKoin` function and provide your Android `Context`
Expand All @@ -48,10 +47,10 @@ From your Koin configuration (in `startKoin { }` block code), you can also confi

### Koin Logging for Android

Within your `KoinApplication` instance, we have an extension `androidLogger` which use the `AndroidLogger()`#
Within your `KoinApplication` instance, we have an extension `androidLogger` which uses the `AndroidLogger()` class.
This logger is an Android implementation of the Koin logger.

Up to you to change this logger if it doesn't suits to your needs.
Up to you to change this logger if it doesn't suit to your needs.

```kotlin
startKoin {
Expand All @@ -69,8 +68,7 @@ You can use Koin properties in the `assets/koin.properties` file, to store keys/
startKoin {
// ...
// use properties from assets/koin.properties
androidFileProperties()

androidFileProperties()
}
```

4 changes: 2 additions & 2 deletions docs/reference/koin-android/viewmodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Your declared component must at least extends the `android.arch.lifecycle.ViewMo
and use the `get()` function to inject dependencies.

:::info
The `viewModel`/`viewModelOf` keyword helps declaring a factory instance of ViewModel. This instance will be handled by internal ViewModelFactory and reattach ViewModel instance if needed.
The `viewModel`/`viewModelOf` keyword helps to declare a factory instance of ViewModel. This instance will be handled by internal ViewModelFactory and reattach ViewModel instance if needed.
It also will let inject parameters.
:::

Expand Down Expand Up @@ -165,7 +165,7 @@ All `stateViewModel` functions are deprecated. You can just use the regular `vie

## Navigation Graph ViewModel

You can scope a ViewModel instance to your Navigation graph. Just retrieve with `by koinNavGraphViewModel()`. You just need your graph Id.
You can scope a ViewModel instance to your Navigation graph. Just retrieve with `by koinNavGraphViewModel()`. You just need your graph id.

```kotlin
class NavFragment : Fragment() {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/koin-android/workmanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ In case both Koin and workFactory1 provided WorkManagerFactory can instantiate a
## A few assumptions
### Add manifest changes in koin lib itself
We can make it one step less for application developers if koin-androidx-workmanager's own manifest disables the default work manager. However it can be confusing since if the app developer don't initialize koin's work manager infrastructure, he'll end up having no usable work manager factories.
We can make it one step less for application developers if koin-androidx-workmanager's own manifest disables the default work manager. However, it can be confusing since if the app developer don't initialize koin's work manager infrastructure, he'll end up having no usable work manager factories.
That's something that checkModules could help: if any class in the project implements ListenableWorker we inspect both manifest and code and make sure they make sense?
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/koin-compose/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This page describe how you can inject your dependencies for your Jetpack Compose

## Starting Koin with Android Jetpack Compose - KoinApplication or KoinAndroidContext

Most of the time, `startKoin` function is used to start Koin in your application. This is done before running any Composable function. You need to setup Compose with your current Koin instance. Use `KoinAndroidContext()` to do so:
Most of the time, `startKoin` function is used to start Koin in your application. This is done before running any Composable function. You need to setting up Compose with your current Koin instance. Use `KoinAndroidContext()` to do so:

```kotlin
@Composable
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/koin-compose/isolated-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Isolated Context with Compose
---

With a Compose application, you can work the same way with an [isolated context](../koin-core/context-isolation.md) to deal with SDK or white label application, in order to not mix your Koin definitions with a end user's one.
With a Compose application, you can work the same way with an [isolated context](../koin-core/context-isolation.md) to deal with SDK or white label application, in order to not mix your Koin definitions with an end user's one.

## Define isolated context

Expand All @@ -24,7 +24,7 @@ Adapt the `MyIsolatedKoinContext` class according your need of initialization

## Setup isolated context with Compose

Now that you have defined an isolated Koin context, we can setup it up to Compose to use it and override all the API. Just use the `KoinIsolatedContext` at the root Compose function. This will propagate your Koin context in all child composables.
Now that you have defined an isolated Koin context, we can seting up it up to Compose to use it and override all the API. Just use the `KoinIsolatedContext` at the root Compose function. This will propagate your Koin context in all child composables.

```kotlin
@Composable
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/koin-compose/multiplatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This page describe how you can inject your dependencies for your Jetpack & Jetbr

## Starting Koin with Compose - KoinApplication or KoinContext

Most of the time, `startKoin` function is used to start Koin in your application. This is done before running any Composable function. You need to setup Compose with your current Koin instance. Use `KoinContext()` to do so:
Most of the time, `startKoin` function is used to start Koin in your application. This is done before running any Composable function. You need to seting up Compose with your current Koin instance. Use `KoinContext()` to do so:

```kotlin
@Composable
Expand Down Expand Up @@ -106,7 +106,7 @@ For this use `unloadOnForgotten` or `unloadOnAbandoned` argument for `rememberKo

## Creating Koin Scope with Composable

The composable function `rememberKoinScope` and `KoinScope` allow to handle Koin Scope in a Composable, follow up current to close scope once Composable is ended.
The composable function `rememberKoinScope` and `KoinScope` allow to handle Koin Scope in a Composable, follow-up current to close scope once Composable is ended.

:::info
this API is still unstable for now
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/koin-core/context-isolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Context Isolation
---


For SDK Makers, you can also work with Koin in a non global way: use Koin for the DI of your library and avoid any conflict by people using your library and Koin by isolating your context.
For SDK Makers, you can also work with Koin in a non-global way: use Koin for the DI of your library and avoid any conflict by people using your library and Koin by isolating your context.

In a standard way, we can start Koin like that:

Expand Down
8 changes: 4 additions & 4 deletions docs/reference/koin-core/definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The result type of your lambda is the main type of your component

## Defining a factory

A factory component declaration is a definition that will gives you a *new instance each time* you ask for this definition (this instance is not retained by Koin container, as it won't inject this instance in other definitions later). Use the `factory` function with a lambda expression to build a component.
A factory component declaration is a definition that will provide you a *new instance each time* you ask for this definition (this instance is not retained by Koin container, as it won't inject this instance in other definitions later). Use the `factory` function with a lambda expression to build a component.

```kotlin
class Controller()
Expand Down Expand Up @@ -84,7 +84,7 @@ val myModule = module {

## Definition: binding an interface

A `single` or a `factory` definition use the type from the their given lambda definition: i.e `single { T }`
A `single` or a `factory` definition use the type from their given lambda definition i.e: `single { T }`
The matched type of the definition is the only matched type from this expression.

Let's take an example with a class and implemented interface:
Expand All @@ -103,7 +103,7 @@ class ServiceImp() : Service {
}
```

In a Koin module we can use the `as` cast Kotlin operator as follow:
In a Koin module we can use the `as` cast Kotlin operator as follows:

```kotlin
val myModule = module {
Expand Down Expand Up @@ -184,7 +184,7 @@ val service : Service by inject(qualifier = named("default"))

`get()` and `by inject()` functions let you specify a definition name if needed. This name is a `qualifier` produced by the `named()` function.

By default Koin will bind a definition by its type or by its name, if the type is already bound to a definition.
By default, Koin will bind a definition by its type or by its name, if the type is already bound to a definition.

```kotlin
val myModule = module {
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/koin-core/dsl-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Constructor DSL
---

Koin now offer a new kind of DSL keyword that allow you to target a class constructor directly, and avoid to to have type your definition within a lambda expression.
Koin now offer a new kind of DSL keyword that allow you to target a class constructor directly, and avoid to have type your definition within a lambda expression.

For a given class `ClassA` with following dependencies:

Expand Down Expand Up @@ -45,7 +45,7 @@ The following keywords are available to build your definition from constructor:
* `scopedOf` - equivalent of `scoped { }` - scoped definition

:::info
Be sure to not use any default value in your constructor, as Koin will try to fill every parameter of it.
Be sure to not use any default value in your constructor, as Koin will try to fill every parameter with it.
:::

## DSL Options
Expand All @@ -71,7 +71,7 @@ Usual options and DSL keywords are available in this lambda:
* `binds(listOf(...))` - add types list for given bean definition
* `createdAtStart()` - create single instance at Koin start

You can also use `bind` or `binds` operator, without any need of lambda:
You can also to use `bind` or `binds` operator, without any need of lambda:

```kotlin
module {
Expand All @@ -81,7 +81,7 @@ module {

## Injected Parameters

With such kind of declaration, you can still use injected parameters. Koin will look in injected parameters and current dependencies to try inject your constructor.
With such kind of declaration, you can still use injected parameters. Koin will look in injected parameters and current dependencies to try to inject your constructor.

Like following:

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/koin-core/dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ As you can see above, we can describe a Koin container configuration in 2 ways:
- `koinApplication` describe a Koin container instance
- `startKoin` describe a Koin container instance and register it in Koin `GlobalContext`

By registering your container configuration into the `GlobalContext`, the global API can use it directly. Any `KoinComponent` refers to a `Koin` instance. By default we use the one from `GlobalContext`.
By registering your container configuration into the `GlobalContext`, the global API can use it directly. Any `KoinComponent` refers to a `Koin` instance. By default, we use the one from `GlobalContext`.

Check chapters about Custom Koin instance for more information.

Expand Down Expand Up @@ -70,7 +70,7 @@ To describe your content in a module, you can use the following functions:
* `bind()` - add type to bind for given bean definition
* `binds()` - add types array for given bean definition
* `scope { // scope group }` - define a logical group for `scoped` definition
* `scoped { //definition }`- provide a bean definition that will exists only in a scope
* `scoped { //definition }`- provide a bean definition that will exist only in a scope

Note: the `named()` function allow you to give a qualifier either by a string, an enum or a type. It is used to name your definitions.

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/koin-core/injection-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ val myModule = module {

## Resolving injected parameters in order

Instead of using `get()` to resolve a parameter, if you have several parameters of the same type you can use the index as follow `get(index)` (also same as `[ ]` operator):
Instead of using `get()` to resolve a parameter, if you have several parameters of the same type you can use the index as follows `get(index)` (also same as `[ ]` operator):

```kotlin
class Presenter(val view : View)
Expand Down Expand Up @@ -85,7 +85,7 @@ val myModule = module {

In addition to `parametersOf`, the following API are accessible:

- `parameterArrayOf`: to use an array of value, and data will be use by its index
- `parameterArrayOf`: to use an array of value, and data will be uses by its index

```kotlin
val params = parameterArrayOf(1,2,3)
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/koin-core/koin-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Koin Component
---

Koin is a DSL to help describe your modules & definitions, a container to make definition resolution. What we need now is
an API to retrieve our instances outside of the container. That's the goal of Koin components.
an API to retrieve our instances outside the container. That's the goal of Koin components.

:::info
The `KoinComponent` interface is here to help you retrieve instances directly from Koin. Be careful, this links your class to the Koin container API. Avoid to use it on classes that you can declare in `modules`, and prefer constructor injection
Expand Down
Loading

0 comments on commit 625cff2

Please sign in to comment.