by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 08 18:44
    scala-steward opened #405
  • Aug 07 06:28
    scala-steward opened #404
  • Aug 01 16:49
    scala-steward opened #403
  • Jul 31 04:42
    scala-steward opened #402
  • Jul 30 04:34
    scala-steward synchronize #371
  • Jul 30 04:05
    shadaj closed #394
  • Jul 30 04:05
    shadaj closed #369
  • Jul 30 04:05
    shadaj closed #368
  • Jul 30 04:04
    shadaj closed #385
  • Jul 30 04:04
    shadaj closed #397
  • Jul 30 04:04
    shadaj closed #398
  • Jul 30 04:04

    shadaj on master

    Update sbt-scalafix to 0.9.19 (… (compare)

  • Jul 30 04:04
    shadaj closed #400
  • Jul 30 04:04
    shadaj synchronize #396
  • Jul 30 04:03
    shadaj synchronize #393
  • Jul 30 04:03

    shadaj on master

    Update scalajs-react:core to 1.… (compare)

  • Jul 30 04:03
    shadaj closed #392
  • Jul 30 04:02

    shadaj on master

    Update sbt-dynver to 4.1.0 (#39… (compare)

  • Jul 30 04:02
    shadaj closed #391
  • Jul 30 04:02

    shadaj on master

    Update sbt to 1.3.13 (#390) (compare)

Răzvan Rotaru
@roti
I decided to give slinky a try :), and have two questions:
when defining the properties of an external component:
  1. can I use other types instead of case classes?
  2. is it a problem if I extend the case class, to have some code sharing for common properties
Shadaj Laddad
@shadaj
@roti
  1. yes, as long as there is a Writer instance available (for example, Seq/Map and js.Any types work out of the box)
  2. nope, that should work just fine!
Jeff Simpson
@fooblahblah
@oyvindberg I was able to get back to the problem I posted and have figured it out. Without providing all the code it might not make total sense, but I had misunderstood how the pagination component should be written and was using my own FunctionalComponent[PagingProps] type instead of the one provided by the scalablytyped bindings FunctionalComponent[TablePaginationActionsProps]. Once I used the correct props an implicit in ReactComponentClass.functionalComponentToClass kicked and everything started working.
Alexis Hernandez
@AlexITC

I'm following the getting started tutorial, got to the intellij step, explaining this but I don't see any message asking me to enable slinky support, is there a way to enable this manually? Thanks

Starting with Slinky 0.5.0, the @react macro annotation is implemented with Macro Paradise to ensure compatibility with future versions of Scala, so a small extra step is required to enable IDE support in IntelliJ (version 2018.3 or higher is required). After loading, your project, uncheck Enable loading external extensions in Settings > Languages & Frameworks > Scala > Extensions, hit apply, re-check it, and hit apply again. After applying these settings and refreshing your SBT project again, IntelliJ will pop up with a request to enable Slinky support.

It's worth adding that I'm on scala 2.13, sjs 1.0.0

Alexis Hernandez
@AlexITC
Apparently it used to be a problem shadaj/slinky#273 but I'm experiencing it
Alexis Hernandez
@AlexITC
How do you tend to propagate dependencies to stateless components? I haven't used react much but the way I have saw is people tend to just declare global constants in js and import them in the component file, they way I see is to just add the dependencies to the Props but I was looking to add them to the constructor, as it's usual in Scala
Shadaj Laddad
@shadaj
@AlexITC does adding libraryDependencies += "me.shadaj" %% "slinky-core-ijext" % slinkyVersion to your build.sbt work? IntelliJ's detection of the support plugin is a bit flaky unfortunately
Alexis Hernandez
@AlexITC
Yes, but I had to use "0.6.5+21-77c195eb" as 0.6.5 doesn't seem to be available
Hernancito
@hernansaab
@hernansaab
Hey there, for whoever is interested. I posted a blog that deals with using monocle + akka + react in scala.js. If this resonates to anybody, I would appreciate some feedback.
https://randomthroughtsfromnowhere.com/
and yes, react slinky as well
Eduardo Gonzalez
@wmeddie
Sweet
Alexis Hernandez
@AlexITC
@hernansaab what's the usefulness for akka on sjs? I have never understand such need
Hernancito
@hernansaab
The idea is that your front end application has a broker that is in charge of updating the application model. Much the same way people use redux in react apps
the components never get to update the model directly, but through a message broker. This allows for quite a few potential benefits such as able to intercept any of these requests
Alexis Hernandez
@AlexITC
I don't see much difference with streams/observables where you can do the same without all the akka drawbacks but it's likely a matter of taste
Bruno Medeiros
@bruno-medeiros

@AlexITC does adding libraryDependencies += "me.shadaj" %% "slinky-core-ijext" % slinkyVersion to your build.sbt work? IntelliJ's detection of the support plugin is a bit flaky unfortunately

I just had same problem, but had to use version "0.6.5+21-77c195eb" too

I hope this does become a pain point moving forward (out of brittleness) or so, since otherwise Slinky seems pretty damn cool. I've also started trying it out
trepidacious
@trepidacious
I'm just trying to do some SVG from slinky, and struggling to find how to make a rect, or any examples of using the SVG tags.
Ramnivas Laddad
@ramnivas
@trepidacious Here is an example of using SVG from Slinky:
import slinky.web.svg._

svg(width := s"${svgSize}px", height := s"${svgSize}px")(
        circle(
            cx := center,
            cy := yPosition,
            r := circleRadius,
            stroke := fill_color,
            fill := fill_color,
            strokeWidth := stroke_width
          )
)
Shadaj Laddad
@shadaj
@bruno-medeiros given that the latest master builds do work with IntelliJ, hopefully the 0.6.6 release will work with IntelliJ out of the box (not running IntelliJ myself which is why I haven't gotten to testing the plugin detection just yet, but this is definitely a top priority)
Bruno Medeiros
@bruno-medeiros
@shadaj what IDE do you use, out of curiosity? VSCode?

Why does Slinky use it's own hot redploy thing:

    if (LinkingInfo.developmentMode) {
      hot.initialize()
    }

I thought webpack-dev-server already supplied auto redeploy, from what I see here: https://scalacenter.github.io/scalajs-bundler/cookbook.html#webpack-dev-server

trepidacious
@trepidacious
@ramnivas Ah thanks, I've got that going now, I had a conflict with the contents of slinky.web.html._, I missed that things like width were coming from that rather than SVG equivalents!
Bruno Medeiros
@bruno-medeiros
Is it valid to use a Future inside a React state? I'm getting some problems with it.
I'm suspecting this message is telling me not to:
Information:(19, 2) Using fallback derivation for type com.babylonhealth.ember.core.fhir.FhirResource (derivation: MacroReadersImpl)
Ramnivas Laddad
@ramnivas
@bruno-medeiros Conceptually, I don't think it is a good idea to keep a Future inside a state. Generally, you shouldn't change state except through setState or its functional component counterparts. Keeping a Future will violate this requirement.
Bruno Medeiros
@bruno-medeiros

I understand it's bad code, but I'm still wondering why it doesn't work. I have this code:

  val f = /// some future
  assert(f.isCompleted)
  component.setState(f)

Then the components get a re-render trigger, but the future in the state, on the render function, is not completed...

Bruno Medeiros
@bruno-medeiros
Here is simplified full component: https://gist.github.com/bruno-medeiros/78b7d2eb5ad4b09b8ac71bd2ad68fa8e
I get isCompleted: true first, and then isCompleted: false, even though it's the same Future.. :open_mouth:
Shadaj Laddad
@shadaj
@bruno-medeiros I use VSCode with Metals. Slinky needs a hot-loading hook in order to serialize the state into a format that can be transported between versions of your code. Scala.js uses an encoding for Scala objects that requires us to serialize the original state, load the new bundle, and then deserialize it into the latest object encoding
Noel Welsh
@noelwelsh
Hi! I was going to submit a PR to update the expo-template-scala but I see that work has been done---it just hasn't been published. Any chance you could publish it soon?
Shadaj Laddad
@shadaj
@noelwelsh just published 35.0.0-1 with the changes!
@bruno-medeiros do you have hot reloading enabled? we serialize the state (which involves converting Future to js.Promise and back) so there may be some weird behavior happening as a result
Noel Welsh
@noelwelsh
Thanks!
Anton Sviridov
@keynmol

(slinky react native) Does anyone else get a problem where after a few reloads their Expo session gets corrupted because fswatch seemingly watches too many files that disappear:

Error: ENOENT: no such file or directory, watch '/home/.../personal/expo-slinky-native/velvetbeam-counter/project/target/scala-2.12/sbt-1.0/classes.bak'
    at FSWatcher.start (internal/fs/watchers.js:169:26)
    at Object.watch (fs.js:1346:11)

And then expo stops auto-reloading.

I'm not sure if there's a way to configure... something to only watch the fastopt file?

(I have no idea what I'm doing when it comes to JS, and the fact that I got this far is a testament to how excellent Slinky is :)
Noel Welsh
@noelwelsh
I haven't seen that error in my explorations of Expo + Slinky.
Since you're still using Scala 2.12 I guess your project is quite old. You might try updating it. There is an expo command to do this. Either expo upgrade or expo update IIRC.
(This is to update the Expo side of it.)
Anton Sviridov
@keynmol
My project is about 5 hours old, I pulled the template today :)
I think the 2.12 is actually what SBT is using - the project itself is configured to 2.13 and that's where the compiled files end up
(SBT is using = that's project/target for SBT's meta-build compilation results, I think )
Noel Welsh
@noelwelsh
Sorry, I don't really understand the inner workings of expo, so I can't help further. Only thing I could find is that React Native uses a file watching service called watchman, and you could configure that to ignore your project directory: https://facebook.github.io/watchman/docs/config.html
Øyvind Raddum Berg
@oyvindberg
You typically need to increase the number of open files for your system/user @keynmol
Vitaly Lavrov
@lavrov
I have been playing with Slinky recently. Managed to build the project with Mill. If anyone is interested check it out https://github.com/lavrov/scalajs-slinky-mill
Cilo Riveros
@cilicio

Hi, I been working with fuctional components, and I need something like componentWillUnmount in react class component. In react documentation says that we must return a function in useEffect Hook like:

  useEffect(() => {
    function handleStatusChange(status) {
      setIsOnline(status.isOnline);
    }
    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
    // Specify how to clean up after this effect:
    return function cleanup() {
      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
    };
  });

I'm trying doing this:

    val cleanup: js.Function = () => {
      dom.console.log("cleanup")
    }

    useEffect({ () =>
      dom.console.log("effect");
      cleanup
    })

But it never prints cleanup. Is this feature supported? Am I wrong about something?

Ramnivas Laddad
@ramnivas
This feature is supported and we use it a lot. Take a look at https://github.com/kladdad/use-slinky-hooks/blob/master/src/main/scala/com/payalabs/slinky/hooks/WindowsHooks.scala to see how it differs from yours.
Shadaj Laddad
@shadaj
@cilicio it should work if you remove the : js.Function, since Slinky looks for a regular Scala function and performs the conversion under-the-hood
@lavrov that's very awesome! could you create a PR to add a link to it from the docs?
Cilo Riveros
@cilicio
It works!! I was having trouble understanding the life cycle of my app. Thank you for your great work.
Alexander Samsig
@Asamsig
Hey @shadaj, I'm working on a personal static website for fun, and I based it on the Slinky docs. Would you be interested in me making a PR with bumps to various NPM dependencies and minor changes to make it work with the newest versions ?
Shadaj Laddad
@shadaj
@Asamsig that would be great! the docs site is using some fairly old package versions, would be nice to have it up to date since it often serves as an example for SSR/prerendering