Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Emerson Coskey
@EmersonCoskey
I got it to work with .runNow() though
so it was a callback
what should I do to make this not dumb though
nafg
@nafg
found it, core-generic
Emerson Coskey
@EmersonCoskey
should I move the .runNow() call into the hook and have the hook accept a _ => Callback?
nafg
@nafg
I'm asking the wrong question. What is UseAnimationFrame.H?
Emerson Coskey
@EmersonCoskey
image.png
just an alias for the Hook val
nafg
@nafg
What is the type of the expression up to and excluding .customBy
Emerson Coskey
@EmersonCoskey
cmon intellij let me copy the text
image.png
nafg
@nafg
@EmersonCoskey why is your hook's input type Double => _? What is the _ supposed to mean?
I don't think it's right -- what do you want it to mean?
Emerson Coskey
@EmersonCoskey
It means the return type is thrown out but I guess every type can be coerced to Unit anyway so that doesn't really make sense
nafg
@nafg
I think you should replace the _ with Callback, and then make def animate return Callback
possibly fn(time).thenRun { ... }
oh wait
Emerson Coskey
@EmersonCoskey
I think animate itself has to be Double => Unit for it to actually be run by the browser
nafg
@nafg
if you use window.requestAnimationFrame you have to call runNow somewhere
so it would only be beneficial if there was an API wrapper for it that already took Callback
Emerson Coskey
@EmersonCoskey
yeah I was gonna make the hook accept a Double => Callback, then call fn(time).runNow() inside animate
nafg
@nafg
What is Parameter?
Emerson Coskey
@EmersonCoskey
meant callback
oops
nafg
@nafg
Bottom line, Callback is basically a wrapper around a function and composable like the IO monad, to actually run the function inside you call runNow
Emerson Coskey
@EmersonCoskey
yeah
nafg
@nafg
It's up to you if you want your hook to take a Unit-returning function, in which case you'd put the runNow in the "higher level" code
or to take a Callback-returning function and call runNow inside the hook (twice I guess, but it's more low level code)
Emerson Coskey
@EmersonCoskey
twice?
image.png
nafg
@nafg
oh. I was thinking if you'd make animate return Callback. But you could do it the way you did it, that's fine
makes more sense your way I guess
Emerson Coskey
@EmersonCoskey
ok
I think if animate returned a callback it wouldn't actually be executed by the browser
nafg
@nafg
Not if you passed it directly to rAF
Emerson Coskey
@EmersonCoskey
window.requestAnimationFrame requires a Double => Unit
nafg
@nafg
Right you'd have to put the runNow there
which would be silly I guess
Emerson Coskey
@EmersonCoskey
ok
nafg
@nafg
window.requestAnimationFrame(d => animate(d).runNow())
BTW doesn't this create an infinite loop so to speak?
Emerson Coskey
@EmersonCoskey
yeah but it's cancelled when the hook is unmounted
nafg
@nafg
Oh I see
Ok great
Emerson Coskey
@EmersonCoskey
cool
Emerson Coskey
@EmersonCoskey
one more thing: are there any good resources for loading svg elements into the vdom?
Emerson Coskey
@EmersonCoskey
nevermind, I figured it out
just have to translate a few svg files into the DSL
Michael Pilquist
@mpilquist
Is anyone using the scalajs-react 2.0 release with Scala 3 and the built-in cats-effect integration? I have core-ext-cats_effect on my classpath before the core dependency (confirmed via sbt> show managedClasspath) but the compiler still resolves the core jar's DefaultEffects object
Ah nevermind! Just had to scroll down in the guide. :)