Miguel Coleto
08/28/2020, 7:14 AMmutableStateOf
always inside of remember
? It is not clear to me what is remember
doing 🤔Javier
08/28/2020, 7:15 AMMiguel Coleto
08/28/2020, 7:28 AMMiguel Coleto
08/28/2020, 7:28 AMMiguel Coleto
08/28/2020, 7:29 AMshikasd
08/28/2020, 7:37 AMshikasd
08/28/2020, 7:41 AMJavier
08/28/2020, 7:56 AMMiguel Coleto
08/28/2020, 8:38 AMppvi
08/28/2020, 8:42 AMMiguel Coleto
08/28/2020, 8:42 AMppvi
08/28/2020, 8:44 AMshikasd
08/28/2020, 8:47 AMMiguel Coleto
08/28/2020, 8:51 AMppvi
08/28/2020, 8:52 AMMiguel Coleto
08/28/2020, 8:54 AMppvi
08/28/2020, 8:54 AMMiguel Coleto
08/28/2020, 9:03 AMMiguel Coleto
08/28/2020, 9:03 AMLeland Richardson [G]
08/28/2020, 2:44 PMuseMemo
fwiwLeland Richardson [G]
08/28/2020, 2:45 PMstate
function we used to have, which was simply a convenience method:
@composable fun <T> state(init: () -> T) = remember { mutableStateOf(init()) }
Leland Richardson [G]
08/28/2020, 2:46 PMremember
it or else when a recomposition happens it will just create a new one instead of using the old one (which is the whole idea behind `remember`… it “remembers” the previous value).Leland Richardson [G]
08/28/2020, 2:48 PMmutableStateOf
is that you don’t need to call it in a composable function. If you are creating state somewhere else (say, in the construction of a class), you can create a state object there as well. This creates use cases that are similar to the new React library recoil if you are familiar with that (and also similar to mobx if you are familiar with that)Leland Richardson [G]
08/28/2020, 2:53 PMMiguel Coleto
08/28/2020, 7:08 PMKarthick
08/28/2020, 7:09 PMLeland Richardson [G]
08/28/2020, 7:22 PMLeland Richardson [G]
08/28/2020, 7:22 PMLeland Richardson [G]
08/28/2020, 7:23 PMmutableStateOf
anywhereKarthick
08/29/2020, 10:57 AM