Chris Lee
07/19/2024, 4:30 PMarrow
is doing wrt context receivers, as that is part of the 1.2.x / 2.x APIs? Please don’t make us go back to .bind()
, code is so much cleaner with context receivers…CLOVIS
07/19/2024, 4:47 PMNorbi
09/09/2024, 4:53 PMwho only do KMPI use context receivers in both JVM and JS projects (and in Common code as well). I guess it is supported in Native, too...
CLOVIS
09/09/2024, 4:54 PMNorbi
09/09/2024, 5:02 PMCLOVIS
09/09/2024, 5:47 PMNorbi
09/09/2024, 6:08 PMcommonMain
and the project has JVM, JS and linuxX64 targets.
(My remoting implementation has support for transporting raised errors between nodes, so it supports raising/handling typed errors occured during remote operations.)
(Sorry, the project is not high quality, it is just for fun and "always experimental" because I don't really have time to work on it 😞)
But in my private projects I found explicit usage of context receivers in JS-only Compose HTML code (in jsMain
, extract):
import org.jetbrains.compose.web.css.SelectorsScope
import org.jetbrains.compose.web.css.selectors.CSSSelector
context(SelectorsScope)
infix fun CSSSelector.child(selector: CSSSelector): CSSSelector = child(this, selector)
Norbi
09/09/2024, 6:20 PMinterface GenericEntityRepository<E, ID : Serializable> {
context(TransactionContext, JpaSessionContext) // JPA operation, transaction is mandatory
fun persist(entity: E): E
...
context(JpaSessionContext) // JPA operation, transaction is optional
fun findOrNull(id: ID): E?
Of course it is just an idea, and experimental as always 🙂, but it seems to work quite well...