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
+19-17Lines changed: 19 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,15 +18,11 @@ data class LoginAction(val username: String,
18
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.
19
19
20
20
```kotlin
21
-
//Dispatch the action in the current Thread
21
+
//Dispatch an action on the main thread synchronously
@@ -55,7 +51,15 @@ class SessionStore : Store<SessionState>() {
55
51
```
56
52
57
53
### Generated code
58
-
MiniActionReducer explanation. //TODO
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.
61
+
62
+
All the generated code is contained inside the class `MiniActionReducer`.
59
63
60
64
### View changes
61
65
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.
@@ -79,13 +83,11 @@ A Task is a basic object to represent an ongoing process. They should be used in
79
83
Having the next code:
80
84
81
85
```kotlin
82
-
83
86
data classLoginAction(valusername:String, valpassword:String)
84
-
data classLoginCompleteAction(valloginTask:Task,
85
-
valuser:User?)
86
-
87
-
data classSessionState(valloginTask:Task = taskIdle(),
88
-
valloggedUser:User? = null)
87
+
data classLoginCompleteAction(valloginTask:Task, valuser:User?)
88
+
```
89
+
```kotlin
90
+
data classSessionState(valloginTask:Task = taskIdle(), valloggedUser:User? = null)
0 commit comments