-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Saved state handle, kotlin 1.8.21, compose compiler 1.4.7, coroutines…
… 1.7.0 (#56) * simplify viewmodel * savedStateHandle * savedStateHandle * fix sideeffects * fix sideeffects * update ios * fix sideeffects * kotlin 1.8.21 * readme * test * autocloseable
- Loading branch information
Showing
26 changed files
with
392 additions
and
166 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
24 changes: 24 additions & 0 deletions
24
...App/src/main/java/com/hoc081098/github_search_kmm/android/rememberStableCoroutineScope.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,24 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.hoc081098.github_search_kmm.android | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import kotlinx.coroutines.CoroutineScope | ||
|
||
/** | ||
* Returns a [StableCoroutineScope] around a [rememberCoroutineScope]. This is useful for event | ||
* callback lambdas that capture a local scope variable to launch new coroutines, as it allows them | ||
* to be stable. | ||
*/ | ||
@Composable | ||
fun rememberStableCoroutineScope(): StableCoroutineScope { | ||
val scope = rememberCoroutineScope() | ||
return remember { StableCoroutineScope(scope) } | ||
} | ||
|
||
/** @see rememberStableCoroutineScope */ | ||
@Stable | ||
class StableCoroutineScope(scope: CoroutineScope) : CoroutineScope by scope |
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
Oops, something went wrong.