partially done navigation/getting-started

This commit is contained in:
InsanusMokrassar 2023-11-07 14:14:40 +06:00
parent 470043d360
commit c9675ec31a
3 changed files with 29 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# Getting started
# Getting started (TBD)
[![Maven Central](https://img.shields.io/maven-central/v/dev.inmo/navigation.core?label=navigation&style=flat-square)](https://github.com/InsanusMokrassar/navigation)
@ -12,11 +12,9 @@ Traditionally, you need to add dependency to your project. Currently, there are
| `Core` | Only necessary tools for your projects | `implementation "dev.inmo:navigation.core:$navigation_version"` |
| `MVVM` | Model-View-ViewModel architecture tools + `Core` components | `implementation "dev.inmo:navigation.mvvm:$navigation_version"` |
# Initialization
# Get started
After you have added your dependency, you should initialize navigation.
There are several important things:
After you have added your dependency, you should initialize navigation. There are several important things:
1. `Config` - it is an instance of any class which extending the `NavigationNodeDefaultConfig` in common case
2. `Factory` - usually object which may create a node or some required part for node
@ -32,6 +30,17 @@ data class MainConfig(
) : NavigationNodeDefaultConfig
```
Both `JS` and `Android` platforms require `ViewModel` for their `MVVM` node variants, but it can be common as well as
`MainConfig`:
```kotlin
class MainViewModel(
node: NavigationNode<MainConfig, NavigationNodeDefaultConfig>
) : ViewModel(
node
)
```
### JS part
```kotlin
@ -50,7 +59,7 @@ class MainNode(
class MainNodeView(
config: MainConfig,
chain: NavigationChain<NavigationNodeDefaultConfig>,
) : View<MainConfig, NavigationNodeDefaultConfig>(
) : View<MainConfig, MainViewModel>(
config,
chain
) {
@ -75,6 +84,10 @@ object MainNodeFactory : NavigationNodeFactory<NavigationNodeDefaultConfig> {
}
```
---
Data below is under TBD
### Android
In Android there is one important note: you will not directly work with nodes. In fact it will be required to create
@ -86,8 +99,15 @@ class MainFragment : NodeFragment<MainConfig, NavigationNodeDefaultConfig>() {
// Your code
// Here will be available: node with type `AndroidFragmentNode`, config: `MainConfig`
}
// MVVM Variant
class MainViewFragment : ViewFragment<MainViewModel, MainConfig>() {
// Will be available also `viewModel` via koin `lazyInject`
override val viewModelClass
get() = MainViewModel::class
}
```
Initialization is different on the platforms, so, lets take a look at each one.
## JS

View File

@ -1,5 +1,7 @@
# Navigation
**This library uses koin as preferred DI in MVVM part**
Navigation is a library for simple management for your app views (or some other logics). In this library there are several
important terms:

View File

@ -47,6 +47,7 @@ nav:
- 'kslog/logging.md'
- 'Navigation':
- 'navigation/index.md'
- 'navigation/getting-started.md'
use_directory_urls: false