Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.mradzinski:rx-firebase:v1.3.0'
}
dependencies {
implementation("com.github.mradzinski:rx-firebase:v1.3.0")
}
<dependency>
<groupId>com.github.mradzinski</groupId>
<artifactId>rx-firebase</artifactId>
<version>v1.3.0</version>
</dependency>
libraryDependencies += "com.github.mradzinski" % "rx-firebase" % "v1.3.0"
:dependencies [[com.github.mradzinski/rx-firebase "v1.3.0"]]
RxJava wrapper for use with the Android Firebase client
dependencies {
compile "io.ashdavies.rxfirebase:{latest-version}"
}
A lightweight RxJava2 wrapper for the Android Firebase client SDK, the user is expected
to own the lifecycle of an asynchronous request via RxJava2 Disposable
handling, however elements
in this library will properly unregister listeners when a Publisher
is cancelled, except in the
case of value setting where it is only possible to register a listener when making the request.
In this case the emitter is checked for it's subscription state.
Whilst the FirebaseDatabase
api is mirrored with RxFirebaseDatabase
it only really uses the
database reference, this is so that the reference hierarchy can easily be traversed through child
and parent elements. Methods requiring FirebaseDatabase
obtain this from the DatabaseReference
and allow you to chain further requests by returning itself.
This library depends on RxTasks
and RxJava2
to provide appropriate api responses.
Therefore asynchronous responses will return, Single
, Completable
and Flowable
respectively.
Many of the operations can be referenced in further detail in the official documentation.
An instance of either RxFirebaseAuth
or RxFirebaseDatabase
can be retrieved using their
respective getInstance
method, which will then use the default Firebase element. Alternatively
this can also be provided as a parameter should you wish to use a custom one.
RxFirebaseAuth has a fairly mirrored api to that of FirebaseAuth
and can in most cases be used
as a drop in replacement. Methods which have no return value will return the instance so that
methods can be chained.
Calls to getCurrentUser()
will return a Maybe emitting the user only if the user is logged in
otherwise it will just call onComplete
immediately.
RxFirebaseDatabase has a simple interface which also mimics that of its Firebase counterpart, at
this time it is not worthwhile to facilitate all the features available via the Query interface
therefore it is possible to use a Query
object with RxFirebaseDatabase.with(query)
.
The main responsibility of RxFirebaseDatabase
is to be able to consume child and value events
using reactive extensions, such as retrieving values, setting and removing values.
One of the main observations here is the consumption of child events, this is achieved through
the use of the ChildEvent
object which has reference to the event type, and data snapshot which
can then be used to resolve the data value.