Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
arkivanov committed Sep 2, 2020
1 parent 65483ad commit 07452a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ Lifecycle-aware components for Jetpack Compose with routing functionality. This

Each `Component` is represented by the [Component](https://github.com/arkivanov/Decompose/blob/master/decompose/src/main/java/com/arkivanov/decompose/Component.kt) interface (actually, should I find a better name?).

### ComponentContext

Each `Component` has an associated [ComponentContext](https://github.com/arkivanov/Decompose/blob/master/decompose/src/main/java/com/arkivanov/decompose/ComponentContext.kt) which implements the following interfaces:
- [RouterFactory](https://github.com/arkivanov/Decompose/blob/master/decompose/src/main/java/com/arkivanov/decompose/RouterFactory.kt), so you can create nested `Routers` in your `Componenets`
- [SavedStateKeeperOwner](https://github.com/arkivanov/Decompose/blob/master/decompose/src/main/java/com/arkivanov/decompose/SavedStateKeeperOwner.kt), so you can preserve any state during configuration changes and/or process death
- AndroidX [LifecycleOwner](https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner), so each `Component` has its own lifecycle
- AndroidX [OnBackPressedDispatcherOwner](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher), so each `Component` can handle back button events
- AndroidX [ViewModelStoreOwner](https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner), so can use AndroidX `ViewModels` in your `Components` (e.g. to retain data over configuration changes)

### The Router

A key unit is the [Router](https://github.com/arkivanov/Decompose/blob/master/decompose/src/main/java/com/arkivanov/decompose/Router.kt).
It is responsible for managing `Component`s, just like `FragmentManager`.
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.

Expand All @@ -28,7 +37,7 @@ There are two sample apps.

This sample can be found [here](https://github.com/arkivanov/Decompose/tree/master/sample/counter/app).
There are three components:
- [Counter](https://github.com/arkivanov/Decompose/blob/master/sample/counter/app/src/main/java/com/arkivanov/counter/app/Counter.kt) - this `Component` just increments the counter every 500 ms. It starts counting once created and stops when destroyed. So `Counter` continues counting while in the back stack, unless recreated.
- [Counter](https://github.com/arkivanov/Decompose/blob/master/sample/counter/app/src/main/java/com/arkivanov/counter/app/Counter.kt) - this `Component` just increments the counter every 500 ms. It starts counting once created and stops when destroyed. So `Counter` continues counting while in the back stack, unless recreated. It uses the AndroidX `ViewModel`, so counting continues after configuration changes.
- [CounterInnerContainer](https://github.com/arkivanov/Decompose/blob/master/sample/counter/app/src/main/java/com/arkivanov/counter/app/CounterInnerContainer.kt) - this `Component` contains the `Counter` and two `Routers` on the left and on the right side. Each `Router` displays its stack of `Counters` and two buttons for navigation. "Next" button pushes another `Counter` to the corresponding `Router`, "Prev" button pops the active `Counter` for the `Router`.
- [CounterRootComponent](https://github.com/arkivanov/Decompose/blob/master/sample/counter/app/src/main/java/com/arkivanov/counter/app/CounterRootContainer.kt) - this `Component` also contains the `Counter`, the `Router` of `CounterInnerContainer` and a button pushing another `CounterInnerContainer` to the stack. System back button is used for backward navigation.

Expand Down
Binary file modified docs/media/SampleCounterDemo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07452a2

Please sign in to comment.