Everything about Slinky -- issues, ideas for features, where it's being used, and more
I'm not sure if this is a bug with Slinky reader, but I am using Reader[MyClass]
when calling a facade that returns a JSON object in order to deserialize it into MyClass
It tricks the scala compiler into assuming the type of the result is MyClass
but unfortunately Option[String]
types are actually just String
causing runtime exceptions
Is there a way to get a Reader
to honor Option
types? MyClass
has an attribute that is Option[String]
, so could Reader[MyClass]
return Some("text")
instead of just "text"
?
I've got a question about Reader
. I'm trying to create a Reader[NoYes]
for:
final case class NoYes(value: Option[Boolean], onChange: Boolean => Unit)
And it blows up in slinky.readwrite.FunctionReaders#function1
when the component tries to call onChange
saying fn is not a function
. It's not a function because fn
is undefined
. It wasn't entirely clear where fn
was coming from, it seemed to be part of the anonymous function.
Stepping through the JS code, the Reader[NoYes]
was trying to read o.value
and o.onChange
instead of the actual properties which is some long fully qualified name with .
replaced with _
. Presumably this is the Reader
macro doing this? I've never had a problem before. Any idea why this one is different?
.onChange
on the read value corresponds to calling .onChange
on the original value.
ReactComponentClass
. Turns out I didn't need this (I accidentally used React.memo
from ST and not the Slinky one).
@shadaj:matrix.org with Slinky being such a great advent, have you (un)seriously considered a Svelte companion-repo to Slinky?: https://svelte.dev/
Looks awesome but I'm too invested in React, unless the tides were to change (some day)...
zetashift: mostly, the API is identical except for not having the @react
macro available, so you'll have to manually use ComponentWrapper
for class components and create a nicer apply
yourself
but other than that, we actually share all the unit test code between Scala 2 and 3 so things are actually mostly source compatible too
@shadaj:matrix.org do you have any plans to allow propagating implicits from components? from what I see, there is a big deal when declaring a component by using def
instead of val
, which is what prevent this approach to work.
I understand that doing this would break exporting components to js but it would be pretty useful to propagate context in a type-safe way
Slinky comes ready with full integration with familiar tools like [...] React DevTools.
@react
annotation on external components only adds the nice apply
method, but doesn't do any other rearranging.
method deriveWriter in trait MacroWriters does not match type slinky.readwrite.Writer[Props]
...
react-dom.development.js:12657 The above error occurred in the <Component> component:
at eval (webpack:///./target/scala-2.13/client-fastopt/slinky.core.FunctionalComponent.js?:77:59)
at eval (webpack:///./target/scala-2.13/client-fastopt/slinky.core.FunctionalComponent.js?:77:59)
at eval (webpack:///./target/scala-2.13/client-fastopt/slinky.core.FunctionalComponent.js?:77:59)
at eval (webpack:///./target/scala-2.13/client-fastopt/slinky.core.FunctionalComponent.js?:77:59)
eval
with the component? Source maps by themselves would only map FunctionalComponent.js
to FunctionalComponent.scala
right?
@react
does (example), this way, you don't need to change the way you create components