-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature flag for statin nudge (#5076)
- Loading branch information
1 parent
73c1ea6
commit 509a319
Showing
8 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/org/simple/clinic/remoteconfig/UpdateFacilityRemoteConfig.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.simple.clinic.remoteconfig | ||
|
||
import android.annotation.SuppressLint | ||
import androidx.work.ExistingWorkPolicy.REPLACE | ||
import androidx.work.WorkManager | ||
import io.reactivex.Observable | ||
import org.simple.clinic.facility.Facility | ||
import org.simple.clinic.remoteconfig.UpdateRemoteConfigWorker.Companion.REMOTE_CONFIG_SYNC_WORKER | ||
import org.simple.clinic.util.scheduler.SchedulersProvider | ||
import javax.inject.Inject | ||
|
||
class UpdateFacilityRemoteConfig @Inject constructor( | ||
private val currentFacilityStream: Observable<Facility>, | ||
private val workManager: WorkManager, | ||
private val schedulers: SchedulersProvider, | ||
) { | ||
|
||
/** | ||
* When facility is changed, then update remote config, since | ||
* user properties are updated in Firebase which are used in | ||
* remote config conditionals | ||
* | ||
* https://firebase.google.com/docs/analytics/user-properties?platform=android | ||
*/ | ||
@SuppressLint("CheckResult") | ||
fun track() { | ||
currentFacilityStream | ||
.subscribeOn(schedulers.io()) | ||
.distinctUntilChanged() | ||
.subscribe { | ||
workManager.enqueueUniqueWork(REMOTE_CONFIG_SYNC_WORKER, REPLACE, UpdateRemoteConfigWorker.createWorkRequest()) | ||
} | ||
} | ||
} |
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
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
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
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