Home > Net >  Can I use Litho from Scala?
Can I use Litho from Scala?

Time:12-16

This may be a wrong understanding, since I don't have very much experience with these things.

I suppose the Litho Java API cannot be used from Scala since it requires code generation that is done on the Java compiler side using Litho macros. Is that right?

But I see there is also a Kotlin API that doesn't rely on macros, so I was wondering if that was exposed as a JVM library it could be imported from Scala and used from there without issues.

CodePudding user response:

I'm not familiar with how the annotation processing can be configured in Scala, and whether it can. We can you codegen API with Kotlin, because it has a very custom support for APT and its setup was targeted to enable processing Kotlin files.

Sadly, Kotlin API was also build with Kotlin features in mind, so it won't work with Scala as is. The best recommendation that we have is to write you Litho components Kotlin with the new API (this is our future) and then you'll be able to use them from Scala entrypoint, like creating a component for the screen and passing some props to it.

  • Related