Skip to content

Commit 86bb7f5

Browse files
authored
Merge pull request #9 from adamint/develop
Readme changes
2 parents 733fbc6 + b460c62 commit 86bb7f5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ This library is available via Maven Central.
1515
<dependency>
1616
<groupId>com.adamratzman</groupId>
1717
<artifactId>spotify-api-kotlin</artifactId>
18-
<version>1.0.2</version>
18+
<version>1.0.3</version>
1919
</dependency>
2020
```
2121

2222
### Gradle
2323
```
24-
compile group: 'com.adamratzman', name: 'spotify-api-kotlin', version: '1.0.1'
24+
compile group: 'com.adamratzman', name: 'spotify-api-kotlin', version: '1.0.3'
2525
```
2626

2727
To use the latest snapshot instead, you must add the Jitpack repository
@@ -85,30 +85,40 @@ PagingObjects are a container for the requested objects (`items`), but also incl
8585
important information useful in future calls. It contains the request's `limit` and `offset`, along with
8686
(sometimes) a link to the next and last page of items and the total number of items returned.
8787

88+
If a link to the next or previous page is provided, we can use the `getNext` and `getPrevious` methods to retrieve
89+
the respective PagingObjects
90+
8891
#### Cursor-Based Paging Objects
8992
A cursor-based paging object is a PagingObject with a cursor added on that can be used as a key to find the next
90-
page of items
93+
page of items. The value in the cursor, `after`, describes after what object to begin the query.
94+
95+
Just like with PagingObjects, you can get the next page of items with `getNext`. *However*, there is no
96+
provided implementation of `after` in this library. You will need to do it yourself, if necessary.
9197

9298
#### LinkedResults
9399
Some endpoints, like `PlaylistsAPI.getPlaylistTracks`, return a LinkedResult, which is a simple wrapper around the
94100
list of objects. With this, we have access to its Spotify API url (with `href`), and we provide simple methods to parse
95101
that url.
96102

97103
### Generic Request
104+
For obvious reasons, in most cases, asynchronous requests via `queue` or `queueAfter` are preferred. However,
105+
the synchronous format is also shown.
106+
98107
```kotlin
99108
val api = SpotifyAPI.Builder("appId", "appSecret").build()
100109
val trackSearch = api.search.searchTrack("Si t'étais là", market = Market.FR)
101110
// with optional parameter of market
102111

103112
fun blocking() {
104113
val trackPaging = trackSearch.complete()
114+
println(trackPaging.items.map { it.name })
105115
// iterate through, see total found, etc. with the paging object..
106116
}
107117

108118
fun async() {
109119
trackSearch.queueAfter(2, TimeUnit.SECONDS, { result ->
110-
// do whatever with the result
111-
// this will be executed 2000 += ~2 ms after invocation
120+
// do whatever with the result.
121+
// this will be executed 2000 +- approximately 5 ms after invocation
112122
})
113123
}
114124
```

0 commit comments

Comments
 (0)