Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firebase database module #62

Closed
cypressious opened this issue May 26, 2017 · 4 comments
Closed

Add firebase database module #62

cypressious opened this issue May 26, 2017 · 4 comments

Comments

@cypressious
Copy link
Contributor

Firebase DB on Android could use some suspend extensions.

@elizarov
Copy link
Contributor

I really hope somebody contributes the corresponding integration. See this document on how to contribute: https://github.com/Kotlin/kotlinx.coroutines/blob/master/integration/README.md

@lucasvsme
Copy link

There is an implementation in this gist made by @beyondeye. Maybe a module can be written with that code.

Renaming some functions and changing their signatures to be extension functions that code would look like this.

@Test
fun `Can write and read from Firebase Database`() = runBlocking {
    val database = FirebaseDatabase.getInstance()
    val messageNode = database.getReference("message")

    messageNode.writeValue("Hello World")  // suspend function

    val message = messageNode.readValue(String::class.java) // suspend function

    assertEquals("Hello World", message)
}

There are other methods implemented, but I couldn't write tests for them yet. Also I'm not so familiar with coroutines yet.

@XinyueZ
Copy link

XinyueZ commented Oct 22, 2017

I think an upgrade to this topic should be transferred to this now.

https://firebase.google.com/docs/firestore/data-model

@lucasvsme
Copy link

@elizarov I've written suspend functions to Task and DatabaseReference here, but I don't know how to integrate the code with the existing Gradle build files of this project. Could you help with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants