https://kotlinlang.org logo
c

Chuck Jazdzewski [G]

05/23/2019, 4:47 PM
This can be done automatically (without needing
Key
) if
Item
uses a
@Pivotal
parameter such as,
Copy code
fun Item(@Pivotal item: DataItem) {
   ...
}
then calls to
Item
automatically track the value of
item
.
e

elizarov

05/23/2019, 4:52 PM
Something that bugs me is why the annotation is
@Pivotal
and not
@Key
or something like it. The choice of the “pivotal” as the name of the feature seems highly unusual to me:
Pivotal, adjective
1. Of crucial importance in relation to the development or success of something else.
2. Fixed on or as if on a pivot.
… and 1st meaning usually springs to mind (pun intended) when reading
@Pivotal
c

Chuck Jazdzewski [G]

05/23/2019, 4:55 PM
The second meaning is more what we were going for. Execution pivots on the value of the parameter.
e

elizarov

05/23/2019, 4:59 PM
But the second meaning is so rarely used, so even having seen its use multiple times I’m still having to pause each time I see it.
c

Chuck Jazdzewski [G]

05/23/2019, 5:00 PM
The first meaning is also there as well as you can rely on the instance of
item
being for any memoization done by the
Item
. An
Image
can mark
src
as pivotal and it knows that it will never be called with a different
src
for the same memoization location in the execution tree. This allows a
launch
of the read to be performed that is composition life-cycle aware and be cancelled automatically when the value of
src
changes at the call site.
l

Leland Richardson [G]

05/23/2019, 5:00 PM
i’d be open to changing the naming here 🙂 I don’t think i’ve met one person who has liked it lol
c

Chuck Jazdzewski [G]

05/23/2019, 5:02 PM
Naming is hard...
e

elizarov

05/23/2019, 5:05 PM
I’d suggest to use “key” as a consistent grammatical base and the choose among
Key
,
Keyed
,
WithKey
, etc for annotation and function names. It is indeed hard, since it has to align with other functions out there that brining some non-visible things into the tree context.
👍 8
For example. One option could be
@Key
annotation and
withKey(key) { ... }
composable function with lower-case letter signifying that it is not really a visual component in any sense (does this distinction make sense? I don’t know)
l

Leland Richardson [G]

05/23/2019, 5:08 PM
yeah i think something like this makes sense
or maybe
keyedBy(...) { ... }
c

Chuck Jazdzewski [G]

05/23/2019, 5:19 PM
I added this to the now growing list of terms we should reconsider.
l

Leland Richardson [G]

05/23/2019, 5:21 PM
👍
4 Views