Skip to content

Instantly share code, notes, and snippets.

@selmanon
Created August 29, 2022 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selmanon/e7b5da14ba86c6c4b42fb2a12217af1e to your computer and use it in GitHub Desktop.
Save selmanon/e7b5da14ba86c6c4b42fb2a12217af1e to your computer and use it in GitHub Desktop.
/**
* toggleAutoDownflow() : method triggered by remote config, should
* be used when notifications based downflow is broken.
*/
private fun toggleAutoDownflow() {
automaticDownflowDisposable?.dispose()
isAutomaticDownflowActivated = remoteConfig.automaticDownflow.activated
automaticDownflowIntervalInMinutes = remoteConfig.automaticDownflow.intervalInMinutes
if (isAutomaticDownflowActivated) {
automaticDownflowDisposable =
Observable
.interval(automaticDownflowIntervalInMinutes, MINUTES)
.doOnNext {
if (autoDownflowTourneeAndOtDisposable == null ||
autoDownflowTourneeAndOtDisposable?.isDisposed == true
) {
downflowTourneeAndOtDisposable = initAutoDownflowTourneeAndOtSubject()
}
autoDownflowTourneeAndOtSubject
.onNext(null)
}
.subscribe({}, { logger.logException(AutomaticDownflowException(it.message)) })
.addTo(compositeDisposable)
}
}
private fun initAutoUpflowObservable() = automaticUpflowObservable
.subscribe({}, { logger.logException(AutomaticUpflowException(it.message)) })
.addTo(compositeDisposable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment