https://kotlinlang.org logo
#compose
Title
# compose
v

Vladimir Ivanov

06/11/2019, 12:30 PM
yep
a

Andrey Kulikov

06/11/2019, 12:34 PM
you will be able to. it is implemented in a way to have a proper multitreading reads and writes. but I am not sure you can easily do it at the moment as it requires some manual additional work right now. you will need to create a Frame object for every thread, I guess we will implement it to work automatically later
🔥 1
g

George Mount

06/11/2019, 2:41 PM
You can do it as long as you have a frame started for the current thread. The UI thread always has a frame, so you can always modify on the UI thread. If, for some reason your lambda is executed off the UI thread, you can see if you have a frame with
inFrame
, start one with
open()
and commit it with
commit()
(all in Frames.kt) Something like this should work: if (!inFrame) { open() // modify state commit() } else { // modify state // let whoever is managing the frame handle the commit }
r

romainguy

06/11/2019, 3:15 PM
We should rename frames to transactions or something :)
7
e

efemoney

06/11/2019, 3:28 PM
Yeah Frames just confused the heck out of me. What exactly is a frame?
g

George Mount

06/11/2019, 3:55 PM
Yep, naming of the API is bad and it should feel bad. Frame = transaction, like Romain said. Essentially, you want all of your changes to happen atomically, so when you
commit()
, all of the changes that you made to the models are considered as changed together.
c

Chuck Jazdzewski [G]

06/11/2019, 4:14 PM
Frames are in memory observable non-durable transactions which will be called transactions in the future, dropping the name frame entirely.
v

Vladimir Ivanov

06/11/2019, 7:24 PM
Did you folks considered batch updates to the tree? For example, when two or three coroutines update the tree almost simultaneously?
l

Leland Richardson [G]

06/11/2019, 7:41 PM
yes - and batching is currently the default
🔥 1
c

Chuck Jazdzewski [G]

06/12/2019, 12:02 AM
@Vladimir Ivanov Are you referring to the tree the composer is managing or a tree data-structure using
@Model
objects as nodes?
2 Views