Thinking about the transformation chaining API for...
# compose
z
Thinking about the transformation chaining API for BasicTextField2. Which one of these do you prefer (see thread)
1:
Copy code
inputTransformation = maxLengthInChars(6)
  .then(allCaps(Locale.current))
where you can define your own transformations as
Copy code
fun allCaps(…): InputTransformation = …
2:
Copy code
inputTransformation = InputTransformation
  .maxLengthInChars(6)
  .allCaps(Locale.current)
where you define your own transformations as
Copy code
fun InputTransformation.allCaps(…): InputTransformation =
  this.then(…)
22
2 is a copy of the
Modifier
style, and requires a bit more ceremony to write custom transformations but is cleaner to use. 1 is simpler to write custom transformations, but harder to discover (no auto-complete) and more verbose to use
The currently-shipping code defines transformations as extension on
InputTransformation.Companion
, which is kind of the worst. Forces you to write
InputTransformation.
before every one, even within the same chain.
a
I’d say 2 because discoverability is more important to me at least
👍🏻 1
👍🏾 1
👍 2
e
Same I agree with 2.
d
Same. 2
z
Wow alright it’s tight but I think 2 is just slightly ahead
😂 14
s
I was thinking of voting for
1
because the chaining of transformations with
then()
makes it clear that they're applied in order, but I immediately remembered that
2
matches how we think of reactive operators and modifiers