Tristan Caron
10/11/2019, 3:01 PMval (text, setText) = +state { "Hello, World!" }
And not
var text by State("Hello, World!")
Same questions for @Composable
actually
@Composable
fun MyComponent() {}
Instead of
fun MyComponent = composable { }
Maybe I should wait for an article about this?Fudge
10/11/2019, 3:12 PMFudge
10/11/2019, 3:13 PMFudge
10/11/2019, 3:14 PM@Composable fun x() = Text(âhelloâ)
becomes
fun x() = composable {
Text(âhelloâ)
}
)Tristan Caron
10/11/2019, 3:20 PMFudge
10/11/2019, 3:30 PMFudge
10/11/2019, 3:31 PMComposer.x() = composable{}
Fudge
10/11/2019, 3:32 PMLuca Nicoletti
10/11/2019, 4:02 PMfun MyComponent() = composable { }
to work đ§Luca Nicoletti
10/11/2019, 4:02 PMLeland Richardson [G]
10/11/2019, 4:13 PMvar text by state { "Hello, World!" }
will be the way it will work. right now the +
is needed. but property delegates are indeed something iâm looking forward to being used here. they didnât work with the new kotlin compiler backend that we rely on until recently thoughLeland Richardson [G]
10/11/2019, 4:13 PMval text by State("Hello World")
compiles, but is subtly wrong, so donât do thatLeland Richardson [G]
10/11/2019, 4:13 PMFudge
10/11/2019, 4:14 PMLeland Richardson [G]
10/11/2019, 4:14 PMLeland Richardson [G]
10/11/2019, 4:15 PMLeland Richardson [G]
10/11/2019, 4:15 PMLeland Richardson [G]
10/11/2019, 4:15 PMLeland Richardson [G]
10/11/2019, 4:16 PMLeland Richardson [G]
10/11/2019, 4:17 PMIcaro Temponi
10/11/2019, 4:17 PMvar text by state { "Hello, World!" }
?Leland Richardson [G]
10/11/2019, 4:21 PMLeland Richardson [G]
10/11/2019, 4:21 PMIcaro Temponi
10/11/2019, 4:21 PMLeland Richardson [G]
10/11/2019, 4:22 PMstate
which is State
implements the componentN operators and the property delegate operatorsTristan Caron
10/11/2019, 4:23 PMclass CounterService {
private val counter = ConflatedBroadcastChannel(0)
fun openSubscription() = counter.openSubscription()
suspend fun increment() {
counter.send(counter.value + 1)
}
}
//
@Composable
fun MyComponent(counterService: CounterService) {
Button(onclick = { counterService.increment() })
Text(counterService.openSubscription())
}
The view would be automatically updated on new values.Leland Richardson [G]
10/11/2019, 4:24 PMLeland Richardson [G]
10/11/2019, 4:25 PMLeland Richardson [G]
10/11/2019, 4:26 PMLeland Richardson [G]
10/11/2019, 4:27 PMTristan Caron
10/11/2019, 4:28 PMAdam Powell
10/11/2019, 9:34 PMTristan Caron
10/11/2019, 11:17 PMSequence
but async, so AsyncSequence
. And channel, for something that doesnât, like a event. I thinking like having an UserService, and if an user change some settings, like color, it is broadcast across the app.
When a component is removed from the tree, of course, we have to think of unsubscribing. But the service will be always running.gildor
10/15/2019, 12:38 AMbroadcast across the appRight, and to subscribe on this broadcast you consume it using Flow. Under the hood it will be a channel for now, or upcoming DataFlow or Flow.share()
Tristan Caron
10/15/2019, 3:30 PMTristan Caron
10/15/2019, 4:32 PMclass CounterService {
private val counter = ConflatedBroadcastChannel(0)
fun openSubscription() = counter.openSubscription()
suspend fun increment() {
counter.send(counter.value + 1)
}
}
Tristan Caron
10/15/2019, 4:45 PMgildor
10/15/2019, 11:26 PM