Skip to content

Commit 2dbbc23

Browse files
ISSUE-138440: rename lifecyclescope to scopr in AndroidWebViewEngine constructor
launch evaluateJavascript with Dispatchers.Main
1 parent 3b1940a commit 2dbbc23

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

engine-webview/src/androidMain/kotlin/com/pega/constellation/sdk/kmp/engine/webview/android/AndroidWebViewEngine.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.pega.constellation.sdk.kmp.engine.webview.common.EngineConfiguration
3737
import com.pega.constellation.sdk.kmp.engine.webview.common.InternalError
3838
import com.pega.constellation.sdk.kmp.engine.webview.common.JsError
3939
import kotlinx.coroutines.CoroutineScope
40+
import kotlinx.coroutines.Dispatchers
4041
import kotlinx.coroutines.launch
4142

4243
import okhttp3.OkHttpClient
@@ -45,7 +46,7 @@ import java.util.concurrent.TimeUnit
4546

4647
class AndroidWebViewEngine(
4748
private val context: Context,
48-
private val lifecycleScope: CoroutineScope,
49+
private val scope: CoroutineScope,
4950
private val okHttpClient: OkHttpClient,
5051
private val nonDxOkHttpClient: OkHttpClient = defaultHttpClient()
5152
) : ConstellationSdkEngine {
@@ -136,7 +137,7 @@ class AndroidWebViewEngine(
136137
put("eventData", JSONObject(event.eventData))
137138
}
138139
val script = "window.sendEventToComponent('${id.id}', '$eventJson')"
139-
this.lifecycleScope.launch {
140+
this.scope.launch(Dispatchers.Main) {
140141
webView.evaluateJavascript(script, null)
141142
}
142143
}

samples/android-cmp-app/src/androidMain/kotlin/com/pega/constellation/sdk/kmp/samples/androidcmpapp/MediaCoActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MediaCoActivity : ComponentActivity() {
3030

3131
val engine = AndroidWebViewEngine(
3232
context = this,
33-
lifecycleScope = this.lifecycleScope,
33+
scope = this.lifecycleScope,
3434
okHttpClient = buildHttpClient(authManager)
3535
)
3636
Injector.init(authManager, engine)

samples/android-compose-app/src/main/java/com/pega/constellation/sdk/kmp/samples/androidcomposeapp/AndroidComposeActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class AndroidComposeActivity : ComponentActivity() {
7878
val caseClassName = AndroidSDKConfig.PEGA_CASE_CLASS_NAME
7979
val engine = AndroidWebViewEngine(
8080
context = this,
81-
lifecycleScope = this.lifecycleScope,
81+
scope = this.lifecycleScope,
8282
okHttpClient = buildHttpClient()
8383
)
8484
sdk = ConstellationSdk.create(config, engine)

test/src/androidDeviceTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ConstellationSdkTest : ConstellationSdkBaseTest() {
1919
fun setup() {
2020
engine = AndroidWebViewEngine(
2121
context = appContext,
22-
lifecycleScope = scope,
22+
scope = scope,
2323
okHttpClient = MockHttpClient(appContext, PegaVersion.v24_1_0),
2424
nonDxOkHttpClient = MockHttpClient(appContext, PegaVersion.v24_1_0)
2525
)

0 commit comments

Comments
 (0)