-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
217 additions
and
205 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
7 changes: 7 additions & 0 deletions
7
mosaic-runtime/src/commonMain/kotlin/com/jakewharton/mosaic/platform.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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
package com.jakewharton.mosaic | ||
|
||
internal expect fun platformDisplay(chars: CharSequence) | ||
|
||
internal expect class AtomicBoolean(initialValue: Boolean) { | ||
|
||
fun set(value: Boolean) | ||
|
||
fun compareAndSet(expect: Boolean, update: Boolean): Boolean | ||
} |
5 changes: 3 additions & 2 deletions
5
mosaic-runtime/src/concurrentMain/kotlin/com/jakewharton/mosaic/blocking.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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package com.jakewharton.mosaic | ||
|
||
import androidx.compose.runtime.Composable | ||
import kotlinx.coroutines.runBlocking | ||
|
||
public fun runMosaicBlocking(body: suspend MosaicScope.() -> Unit) { | ||
public fun runMosaicBlocking(content: @Composable () -> Unit) { | ||
runBlocking { | ||
runMosaic(body) | ||
runMosaic(content) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
package example | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import com.jakewharton.mosaic.MosaicScope | ||
import com.jakewharton.mosaic.ui.Text | ||
import kotlinx.coroutines.delay | ||
|
||
suspend fun MosaicScope.runCounter() { | ||
// TODO https://github.com/JakeWharton/mosaic/issues/3 | ||
var count by mutableStateOf(0) | ||
@Composable | ||
fun Counter() { | ||
var count by remember { mutableStateOf(0) } | ||
|
||
setContent { | ||
Text("The count is: $count") | ||
} | ||
Text("The count is: $count") | ||
|
||
for (i in 1..20) { | ||
delay(250) | ||
count = i | ||
LaunchedEffect(Unit) { | ||
for (i in 1..20) { | ||
delay(250) | ||
count = i | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ package example | |
import com.jakewharton.mosaic.runMosaic | ||
|
||
suspend fun main() = runMosaic { | ||
runCounter() | ||
Counter() | ||
} |
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 |
---|---|---|
|
@@ -5,5 +5,5 @@ package example | |
import com.jakewharton.mosaic.runMosaic | ||
|
||
suspend fun main() = runMosaic { | ||
runCounter() | ||
Counter() | ||
} |
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
Oops, something went wrong.