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
Once you have created your models and services, making a request is a piece of cake
125
+
126
+
- Simple Request
127
+
```kotlin
128
+
PostService.getPosts(this)
129
+
.post()
130
+
```
131
+
132
+
- Request with Callbacks
133
+
```kotlin
134
+
PostService.getPosts(this)
135
+
.success {
136
+
TODO("Use your data from $it")
137
+
// use $it.userId to get userId from Post
138
+
}
139
+
.failure {
140
+
TODO("Let user know that the request has failed")
141
+
}
142
+
.post()
143
+
}
144
+
```
145
+
146
+
And you're done ✅
147
+
148
+
## Enable Offline Mode
149
+
150
+
To make a request to start caching data for offline usage, just pass a unique `offlineEndpoint` . **Not to be used with data creation/modification requests**.
151
+
152
+
### When fetching a list of items
153
+
```kotlin
154
+
ConnectionHelper(ctx, Post::class.java)
155
+
.payload(post)
156
+
.endpoint("/posts")
157
+
.offlineEndpoint("posts")
158
+
.loader(false)
159
+
```
160
+
161
+
### When fetching a single item (*pass the unique item it as second parameter*)
162
+
```kotlin
163
+
ConnectionHelper(ctx, Post::class.java)
164
+
.payload(post)
165
+
.endpoint("/posts/$postId")
166
+
.offlineEndpoint("posts", postId)
167
+
.loader(false)
168
+
```
169
+
170
+
### Recommended attributes for `offlineEndpoint`
171
+
- should be unique
172
+
- avoid using any symbols
173
+
- cannot be empty (empty indicates that request doesn't support offline mode)
0 commit comments