|
5 | 5 | 🔓 <a href="https://teamhub.typeform.com/to/uSS8cv">Request Early Access</a>
|
6 | 6 | <h4></h4>
|
7 | 7 |
|
8 |
| -The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the [Firebase Android SDK Kotlin Extensions](https://firebase.github.io/firebase-android-sdk/reference/kotlin/firebase-ktx/) but it also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting *iOS*, *Android* or *JS*. |
| 8 | +The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the [Firebase Android SDK Kotlin Extensions](https://firebase.github.io/firebase-android-sdk/reference/kotlin/firebase-ktx/) but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting *iOS*, *Android* or *JS*. |
9 | 9 |
|
10 | 10 | ## Kotlin-first design
|
11 | 11 |
|
12 |
| -Unlike the Kotlin Extensions for the Firebase Android SDK this project does not extend a Java based SDK so we get to use the full power of Kotlin. |
| 12 | +Unlike the Kotlin Extensions for the Firebase Android SDK this project does not extend a Java based SDK so we get the full power of Kotlin including coroutines and serialization! |
13 | 13 |
|
14 | 14 | <h4><a href="https://kotlinlang.org/docs/tutorials/coroutines/async-programming.html#coroutines">Suspending functions</a></h4>
|
15 | 15 |
|
16 | 16 | Asynchronous operations that return a single or no value are represented by suspending functions in the SDK instead of callbacks, listeners or OS specific types such as [Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task), for example:
|
17 | 17 |
|
18 |
| -`suspend fun signInWithCustomToken(token: String): AuthResult` |
| 18 | +```kotlin |
| 19 | +suspend fun signInWithCustomToken(token: String): AuthResult |
| 20 | +``` |
19 | 21 |
|
20 |
| -Note in the case of functions which do not return a value the use of suspending functions means the default behavior when calling these functions is to wait for them to complete |
| 22 | +It is important to remember that unlike a callback based API, wating for suspending functions to complete is implicit and so if you don't want to wait for the result you can `launch` a new coroutine: |
| 23 | + |
| 24 | +```kotlin |
| 25 | +//TODO don't use GlobalScope |
| 26 | +GlobalScope.launch { |
| 27 | + Firebase.auth.signOut() |
| 28 | +} |
| 29 | +``` |
21 | 30 |
|
22 | 31 | <h4><a href="https://kotlinlang.org/docs/reference/coroutines/flow.html">Flows</a></h4>
|
23 | 32 |
|
24 |
| -Asynchronous streams of values are represented by Flows in the SDK instead of repeatedly Invoked callbacks or listeners, for example: |
| 33 | +Asynchronous streams of values are represented by Flows in the SDK instead of repeatedly invoked callbacks or listeners, for example: |
25 | 34 |
|
26 | 35 | `val snapshots: Flow<DocumentSnapshot>`
|
27 | 36 |
|
| 37 | + |
| 38 | + |
28 | 39 | <h4><a href="https://github.com/Kotlin/kotlinx.serialization">Serialization</a></h4>
|
29 | 40 |
|
30 | 41 | <h4><a href="https://kotlinlang.org/docs/reference/functions.html#named-arguments">Named arguments</a></h4>
|
|
0 commit comments