utikeev
07/25/2019, 8:41 AMeffector
lib for Kotlin and stumbled upon the next problem. There are different config types in effector
which are normalised before passing to factory. Normalisation uses Object.assign
and leads to erasure of property getters, so the result object has generated property names, but no getters with initial names:
nameOrConfig: createEffectConfig$ObjectLiteral
handler_80ch0g$_0: ƒ fetchUser$lambda(payload)
name_7uss69$_0: "Get user"
handler: (...)
name: (...)
after normalisation becomes
config:
handler_80ch0g$_0: ƒ fetchUser$lambda(payload)
name_7uss69$_0: "Get user"
and handler
and name
properties are now unreachable for the library.
The only way I found is using js { ... }
wrapper and return dynamic object instead. Is there more Kotlin way to approach this problem?Roman Artemev [JB]
07/25/2019, 11:57 AMfield
? Is it possible to change kotlin code without usage of field
?utikeev
07/25/2019, 4:06 PMconfig
has name
property which actually is name_7uss69$_0
with getter, and library does (simply speaking) something like that:
const newConfig = Object.assign({}, opts, preprocess(config))
return newConfig.name
So newConfig
has name_7uss69$_0
, but no getter.
And initial config
is passed as a parameter to the external function:
external fun <Payload, Done> createEffect(config: dynamic): EffectorEffect<Payload, Done, Any>
For now I’ve solved it like that:
fun <Payload, Done> createEffect(
name: String,
handler: (payload: Payload) -> Promise<Done>): EffectorEffect<Payload, Done, Any> =
createEffect(config = js {
this.name = name
this.handler = handler
})
I guess it relates to this issue: https://youtrack.jetbrains.com/issue/KT-17683