CLOVIS
02/22/2023, 3:57 PMCLOVIS
02/22/2023, 3:58 PMCLOVIS
02/22/2023, 3:59 PMCLOVIS
02/22/2023, 3:59 PMCLOVIS
02/22/2023, 5:04 PMinterface MyComponents : UIMetadata, Buttons, Chips…
you can expect-actual (or just implement) this interface via delegation to use existing implementations, or just create your own:
class MaterialComponents : MyComponents, Buttons by MaterialButtons, Chips by MaterialChips…
and then, you can typesafely declare components that work for any implementation you provided:
@Composable
context(MyComponents)
fun UserList(users: List<User>) {
Column {
for (user in users) …
}
}
Because of the receiver, this allows to easily know if all components used are available for all implementations:
@Composable
context(CLI)
fun UserList(…) {
// Here, you can call only components that are declared to be implemented for CLI applications
}
Currently, we have a few dozen components implemented, but they prove this structure works. I'm very interested in having other people's opinions on where this can go.Landry Norris
02/22/2023, 5:31 PMDavid Herman
02/22/2023, 5:45 PMDavid Herman
02/22/2023, 5:46 PMRobert Jaros
02/22/2023, 5:59 PMLandry Norris
02/23/2023, 4:41 PMCLOVIS
02/23/2023, 8:25 PMCLOVIS
02/25/2023, 4:04 PMCLOVIS
02/25/2023, 4:09 PMCLOVIS
03/01/2023, 5:19 PM@Composable
fun Button(
…
onClick: suspend () -> Unit,
scope: CoroutineScope = rememberCoroutineScope(),
…
)
This pattern is very convenient because it allows to use coroutines in all events, and it allows the button to automatically display a loading indicator if the event is taking too long. However, there is no good place to document it… I cannot copy-paste the documentation on each component that uses this pattern.
I'm considering creating a concepts
or patterns
package in core
that would only contain 'fake symbols' that can be documented. They would never be used in an actual application, but it would be easy to refer to them in documentation. For example, a dummy type alias:
/**
* Explain the pattern here.
*/
typealias PatternName = Nothing // useless, takes no space in the final application
Do you think this approach is a good idea?
1️⃣ yes, using a typealias = Nothing
(but typealiases do not get their own pages in Dokka, so it would be hard to link to them)
2️⃣ yes, using an empty object
(but it will exist in the final binary)
3️⃣ no, use some kind of external documentation website (cannot see the explanation in the IntelliJ documentation popup, hard for users to know if the website matches the version of the library that they're using)
🔢 neutralLandry Norris
03/02/2023, 12:11 AMCLOVIS
03/09/2023, 9:09 AMCLOVIS
03/09/2023, 9:12 AMCLOVIS
03/27/2023, 6:51 PMCLOVIS
03/27/2023, 6:51 PM