Skip to content

Instantly share code, notes, and snippets.

@npatarino
Created August 6, 2018 15:31
Show Gist options
  • Save npatarino/460194fc063ce92e18f7caedecf063cb to your computer and use it in GitHub Desktop.
Save npatarino/460194fc063ce92e18f7caedecf063cb to your computer and use it in GitHub Desktop.
override fun all(): Future<List<Either<NetError, Task>>> = Future(async(CommonPool) {
val snapshot: DataSnapshot = suspendCoroutine { cont: Continuation<DataSnapshot> ->
taskReference.addValueEventListener(object : ValueEventListener {
override fun onCancelled(error: DatabaseError) {
cont.resumeWithException(IOException("Error retrieving data"))
}
override fun onDataChange(dataSnapshot: DataSnapshot) {
cont.resume(dataSnapshot)
}
})
}
listOf(Either.Left(NetError.Unknown))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment