-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[](https://bintray.com/arkivanov/maven/mvikotlin/_latestVersion) | ||
[](https://bintray.com/arkivanov/maven/decompose/_latestVersion) | ||
[](http://www.apache.org/licenses/LICENSE-2.0) | ||
 | ||
[](https://twitter.com/arkann1985) | ||
|
||
## Decompose | ||
|
||
|
@@ -11,6 +11,26 @@ Supported targets: | |
- iosX64, iosArm64 | ||
- JavaScript | ||
|
||
### Setup | ||
|
||
Add Bintray repository to your root build.gradle file: | ||
|
||
```groovy | ||
repositories { | ||
maven { | ||
url "https://dl.bintray.com/arkivanov/maven" | ||
} | ||
} | ||
``` | ||
|
||
Add Decompose dependency to your build.gradle: | ||
|
||
```groovy | ||
implementation "com.arkivanov.decompose:decompose:<version>" | ||
``` | ||
|
||
## Overview | ||
|
||
### Component | ||
|
||
Each `Component` is represented by the [Component](https://github.com/arkivanov/Decompose/blob/master/decompose/src/commonMain/kotlin/com/arkivanov/decompose/Component.kt) interface (actually, should I find a better name?). | ||
|
@@ -26,20 +46,19 @@ Each `Component` has an associated [ComponentContext](https://github.com/arkivan | |
|
||
### The Router | ||
|
||
A key unit is the [Router](https://github.com/arkivanov/Decompose/blob/master/decompose/src/commonMain/kotlin/com/arkivanov/decompose/Router.kt). | ||
It is responsible for managing `Components`, just like `FragmentManager`. | ||
A key unit is the [Router](https://github.com/arkivanov/Decompose/blob/master/decompose/src/commonMain/kotlin/com/arkivanov/decompose/Router.kt). It is responsible for managing `Components`, just like `FragmentManager`. | ||
|
||
The `Router` supports back stack and so each `Component` has its own `Lifecycle`. Each time a new `Component` is pushed, the currently active `Component` is stopped. When a `Component` is popped from the back stack, the previous `Component` is resumed. This allows business logic to run while the component is in the back stack. | ||
|
||
Each `Component` is created based on an associated `Configuration`. `Configurations` can be persisted via Android's `saved state`, thus allowing back stack restoration after configurations change or process death. When the back stack is restored, only currently active `Components` are recreated. All others in the back stack remain destroyed, and recreated on demand when navigating back. | ||
|
||
`Routers` can be nested, and each `Component` can have more than one `Router`. | ||
|
||
### Sample apps | ||
## Sample apps | ||
|
||
There are two sample apps. | ||
|
||
#### Sample counter app | ||
### Sample counter app | ||
|
||
This sample demonstrates the following features: | ||
- Nested `Components` | ||
|
@@ -60,11 +79,11 @@ Content: | |
|
||
<img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleCounterDemo.gif" width="196"> <img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleCounterIos.png" width="196"> <img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleCounterJs.png" width="196"> | ||
|
||
##### Sample Counter Component structure | ||
#### Sample Counter Component structure | ||
|
||
<img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleCounterStructure.png" width="384"> | ||
|
||
#### Sample todo app | ||
### Sample todo app | ||
|
||
This sample can be found [here](https://github.com/arkivanov/Decompose/tree/master/sample/todo). | ||
|
||
|
@@ -85,7 +104,7 @@ There are multiple `Components`, each in a separate module: | |
- [edit](https://github.com/arkivanov/Decompose/tree/master/sample/todo/edit) - provides the ability to edit a selected todo item. | ||
- [root](https://github.com/arkivanov/Decompose/tree/master/sample/todo/root) - aggregates both `main` and `edit` components and uses `Router` to switch between them. | ||
|
||
##### Sample Todo Component structure | ||
#### Sample Todo Component structure | ||
|
||
<img src="https://raw.githubusercontent.com/arkivanov/Decompose/master/docs/media/SampleTodoStructure.png" width="512"> | ||
|
||
|