You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-51Lines changed: 9 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,12 @@ Feature development using Mini is fast compared to traditional architectures (li
7
7
8
8
## How to Use
9
9
### 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.
11
10
12
-
```kotlin
13
-
data classLoginAction(valusername:String,
14
-
valpassword:String) : Action
15
-
```
11
+
🚧WIP🚧
16
12
17
13
### 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🚧
19
16
20
17
```kotlin
21
18
//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
30
27
31
28
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.
32
29
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 classSessionState(valloginTask:Task = taskIdle(),
36
-
valloggedUsername:String? = null)
37
-
38
-
39
-
classSessionStore : 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**.
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.
61
35
62
-
All the generated code is contained inside the class `MiniActionReducer`.
36
+
🚧WIP🚧
63
37
64
38
### View changes
65
39
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() {
185
159
## Setting Up
186
160
187
161
### Import the library
188
-
To setup Mini in your application, first you will need to add the library itself together with the annotation processor:
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.
197
162
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🚧
199
164
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)
0 commit comments