Skip to content

Commit

Permalink
Replace start method with experiments injected via constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
renanferrari committed May 4, 2021
1 parent 4c8164c commit 3eb27b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions WordPress/src/main/java/org/wordpress/android/WordPress.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public class WordPress extends MultiDexApplication implements HasAndroidInjector
@Inject AppConfig mAppConfig;
@Inject ImageEditorFileUtils mImageEditorFileUtils;
@Inject ExPlat mExPlat;
@Inject Set<Experiment> mExperiments;
@Inject @Named(APPLICATION_SCOPE) CoroutineScope mAppScope;

// For development and production `AnalyticsTrackerNosara`, for testing a mocked `Tracker` will be injected.
Expand Down Expand Up @@ -369,7 +368,7 @@ public void onConnectionSuspended(int i) {
mStoryMediaSaveUploadBridge.init(this);
ProcessLifecycleOwner.get().getLifecycle().addObserver(mStoryMediaSaveUploadBridge);

mExPlat.start(mExperiments);
mExPlat.forceRefresh();
}

protected void initWorkManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.util.experiments

import dagger.Lazy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.wordpress.android.BuildConfig
Expand All @@ -21,20 +22,14 @@ import javax.inject.Singleton
@Singleton
class ExPlat
@Inject constructor(
private val experiments: Lazy<Set<Experiment>>,
private val experimentStore: ExperimentStore,
private val appLog: AppLogWrapper,
@Named(APPLICATION_SCOPE) private val coroutineScope: CoroutineScope
) {
private val platform = Platform.WORDPRESS_ANDROID
private val activeVariations = mutableMapOf<String, Variation>()

private var experimentNames = emptyList<String>()

fun start(experiments: Set<Experiment>) {
experimentNames = experiments.map { it.name }
appLog.d(T.API, "ExPlat: starting with $experimentNames")
forceRefresh()
}
private val experimentNames by lazy { experiments.get().map { it.name } }

fun refreshIfNeeded() {
refresh(refreshStrategy = IF_STALE)
Expand Down

0 comments on commit 3eb27b7

Please sign in to comment.