Skip to content

Commit 997eb07

Browse files
author
Pablo Orgaz
authored
Update README.md
1 parent 0ae84b6 commit 997eb07

File tree

1 file changed

+9
-51
lines changed

1 file changed

+9
-51
lines changed

README.md

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ Feature development using Mini is fast compared to traditional architectures (li
77

88
## How to Use
99
### Actions
10-
Actions are helpers that pass data to the Dispatcher. They represent use cases of our application and are the start point of any state change made during the application lifetime.
1110

12-
```kotlin
13-
data class LoginAction(val username: String,
14-
val password: String) : Action
15-
```
11+
🚧WIP🚧
1612

1713
### Dispatcher
18-
The dispatcher receives Actions and broadcast payloads to registered callbacks. The instance of the Dispatcher must be unique across the whole application and it will execute all the logic in the main thread making state muations synchronous.
14+
15+
🚧WIP🚧
1916

2017
```kotlin
2118
//Dispatch an action on the main thread synchronously
@@ -30,36 +27,13 @@ The Stores are holders for application state and state mutation logic. In order
3027

3128
The state is plain object (usually a data class) that holds all information needed to display the view. State should always be inmutable. State classes should avoid using framework elements (View, Camera, Cursor...) in order to facilitate testing.
3229

33-
Stores subscribe to actions to change the application state after a dispatch. Mini generates the code that links dispatcher actions and stores using the `@Reducer` annotation over a **non-private function that receives an Action as parameter**. It can also receive a state for unitary testing purposes.
34-
```kotlin
35-
data class SessionState(val loginTask : Task = taskIdle(),
36-
val loggedUsername : String? = null)
37-
38-
39-
class SessionStore : Store<SessionState>() {
30+
Stores subscribe to actions to change the application state after a dispatch. Mini generates the code that links dispatcher actions and stores using the `@Reducer` annotation over a **non-private function that receives an Action as parameter**.
4031

41-
@Reducer
42-
fun login(action: LoginAction): SessionState {
43-
return state.copy(loginTask = taskRunning())
44-
}
45-
46-
@Reducer
47-
fun loginComplete(action: LoginCompleteAction, state: SessionState): SessionState {
48-
return state.copy(loginTask = taskSuccess(), loggedUsername = action.name)
49-
}
50-
}
51-
```
32+
🚧WIP🚧
5233

5334
### Generated code
54-
Mini uses an annotation processor to generate code automatically based on the `@Reducer` annotations in your code.
55-
Annotating a function inside a `Store` with `@Reducer` will generate all the code needed to call the right methods of your stores when an `Action` goes though the `Dispatcher`.
56-
57-
A method annotated with `@Reducer` must:
58-
- Receive a class that inherits from `Action` by parameter
59-
- Return an State of the same type that the store which contains the function
60-
- Optionally, it can receive also another `State` as second parameter. This is useful for unitary testing purposes.
6135

62-
All the generated code is contained inside the class `MiniActionReducer`.
36+
🚧WIP🚧
6337

6438
### View changes
6539
Each ``Store`` exposes a custom `StoreCallback` though the method `observe` or a `Flowable` if you wanna make use of RxJava. Both of them emits changes produced on their states, allowing the view to listen reactive the state changes. Being able to update the UI according to the new `Store` state.
@@ -185,25 +159,9 @@ fun login_redirects_to_home_with_success_task() {
185159
## Setting Up
186160

187161
### Import the library
188-
To setup Mini in your application, first you will need to add the library itself together with the annotation processor:
189-
```groovy
190-
implementation 'com.github.pabloogc:Mini:1.1.0'
191-
kapt 'com.github.pabloogc.Mini:mini-processor:1.1.0'
192-
androidTestImplementation 'com.github.pabloogc.Mini:mini-android-testing:1.1.0' //Optional
193-
```
194-
195-
### Setting up your App file
196-
After setting it up on your gradle application. You will need to initialize a `Dispatcher` unique instance in your application together with a list of `Stores`. To achieve this you can use your favorite dependency injection framework.
197162

198-
With your Dispatcher and Stores ready, you will need to add the `MiniActionReducer` which is auto-generated depending of your `Stores` and `Reducers`.
163+
🚧WIP🚧
199164

200-
Finally, if you want to add *action-state* changes logging to your application you can add the `LoggerInterceptor` provided by the library or create your own one.
201-
```kotlin
202-
val actionReducer = MiniActionReducer(stores = stores())
203-
val loggerInterceptor = CustomLoggerInterceptor(stores().values)
204-
205-
dispatcher.addActionReducer(actionReducer)
206-
dispatcher.addInterceptor(loggerInterceptor) //Optional
165+
### Setting up your App file
207166

208-
FluxUtil.initStores(stores())
209-
```
167+
🚧WIP🚧

0 commit comments

Comments
 (0)