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
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@ You can execute asynchronous tasks in this ViewModel instance and this class is
10
10
11
11

12
12
13
-
<b>How to implement</b>:
13
+
How to implement
14
+
--------
14
15
15
16
1. Create an interface for your <b>View</b> by extending [IView](library/src/main/java/eu/inloop/viewmodel/IView.java). We will call it IUserListView for this example.
16
17
@@ -41,7 +42,8 @@ You can execute asynchronous tasks in this ViewModel instance and this class is
41
42
}
42
43
```
43
44
44
-
<b>How to use</b>:
45
+
How to use
46
+
--------
45
47
46
48
You can forward user interaction from the View into the ViewModel simply by calling:
47
49
@@ -53,10 +55,18 @@ The same goes for the opposite direction, when your asynchronous operation in th
53
55
54
56
```java
55
57
if (getView() !=null) {
56
-
getView().showUsers(userList);
58
+
getView().showUsers(userList);
57
59
}
58
60
```
59
61
62
+
Your Fragment argument Bundle and Activity intent Bundle is forwarded to the ViewModel's onCreate method, which you can override to read the initial arguments for the ViewModel.
A unique global ID is generated for the first time your Fragment or Activity is shown. This ID is passed on during orientation changes. Opening another instance of the same Fragment or Activity will result in a different ID. The ID is unique screen identifier. A ViewModel class is created and bound to this ID. The corresponding ViewModel instance is attached to your Fragment or Activity after an orientation change or if you return to the fragment in the back stack.
@@ -95,5 +105,7 @@ or Maven:
95
105
<version>0.2</version>
96
106
</dependency>
97
107
```
108
+
Build and study sample application from source code or download from Google Play.<br/>
<b>Development status:</b> Used internally at company on some production applications. Library is under development and API changes might occur anytime. But it should be usuable at this point without any big issues (like memory leaks).
0 commit comments