Created
June 19, 2018 12:42
-
-
Save ppicas/a3ed12ef0e803b26e3d2d5f200557ba7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FirebasePushUpdates : PushUpdates { | |
val jobSubject = PublishSubject.create<Job>().toSerialized() | |
override val jobs: Observable<Job> = jobSubject | |
} | |
class FirebaseMessagingService : FirebaseMessagingService() { | |
override fun onMessageReceived(remoteMessage: RemoteMessage) { | |
val job = parseJob(removeMessage.data) | |
FirebasePushUpdates.jobSubject.onNext(job) | |
} | |
private fun parseJob(data: String) : Job { | |
// ... | |
} | |
} | |
class MergePushUpdates(pushUpdates: List<PushUpdates>) : PushUpdates { | |
override val jobs: Observable<Job> = | |
Observable.merge(pushUpdates.map { it.jobs }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment