Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 13 10:59

    fdietze on master

    Scala 2.13.8, Outwatch 1.0.0-RC… (compare)

  • Jan 13 10:59

    fdietze on update-dependencies

    (compare)

  • Jan 13 10:59
    fdietze closed #34
  • Jan 13 10:54
    fdietze opened #34
  • Jan 13 10:54

    fdietze on update-dependencies

    Scala 2.13.8, Outwatch 1.0.0-RC… (compare)

  • Jan 13 10:50

    fdietze on master

    Aggregate scalaStewardUpdater i… (compare)

  • Jan 13 10:49

    fdietze on master

    Revert "Update sbt-giter8 to 0.… Use template in CI (compare)

  • Jan 13 10:49

    fdietze on execute-template

    (compare)

  • Jan 13 10:49
    fdietze closed #33
  • Jan 13 10:46
    fdietze opened #33
  • Jan 13 10:46

    fdietze on execute-template

    Revert "Update sbt-giter8 to 0.… Use template in CI (compare)

  • Jan 13 08:56
    mergify[bot] labeled #570
  • Jan 13 08:55
    scala-steward opened #570
  • Jan 12 08:05

    mergify[bot] on master

    Update silencer-lib, silencer-p… (compare)

  • Jan 12 08:05
    mergify[bot] closed #569
  • Jan 12 08:00
    mergify[bot] labeled #569
  • Jan 12 08:00
    scala-steward opened #569
  • Jan 11 16:58

    fdietze on master

    Deploy website Deploy website … (compare)

  • Jan 11 16:54

    fdietze on v1.0.0-RC5

    (compare)

  • Jan 11 14:12

    fdietze on mdoc-exports-not-defined

    (compare)

moritz bust
@busti

@bblfish:matrix.org I was personally drawn to outwach because it combined the syntax of scalatags with monix, a library I had already used before. We have since replaced monix with an abstraction that makes it possible to use other reactive programming libraries such as scala.Rx and perhaps fs2, we have also adopted the F[_] pattern for effects, which basically allows me to share large portions of code between my backend server and the frontend and something that makes the library stand out more than it did when I first started using it.
There is still a lot of work going on regarding the streaming and effect abstraction parts though to allow for more library support such as zio and zio-streams.

I must admit that I am not as familiar with laminar as I want to be, but the whole ownership concept is super interesting and definitely something I want to take a deeper dive into in the future.
There is probably some interesting stuff that laminar does that we cannot do as easily since it's very tightly integrated with it's own streaming lib.

Since we want to support all kinds of streaming libraries handling lifecycles outside of those that arise from the DOM is outside our scope and must be handled by those libraries. I.e. I would love to know how fs2 solves the problems the airstream docs are talking about.

I personally like the F[_] functional programming style for libraries which is why I avoided using laminar in the past and I would like to migrate my front-end to zio in the future which is why I am looking into supporting it at the moment.

That being said, interacting with the dom directly is really interesting and probably somewhat faster. We currently use the javascript v-dom library (snabbdom)[https://github.com/snabbdom/snabbdom] for dom interaction.
I have some ideas on how we could model dom diffing directly in outwatch I never did anything specific.

bblfish
@bblfish:matrix.org
[m]
Thanks for the updates.
@busti Re the speed of updating the DOM directly or virtually, I can see arguments going both ways. If the events can be directed to small parts of the virtual dom so that it does not need to be recomputed completely, and if writing the diff can be done more efficiently in one go. rather than a lot of small changes, I could see the VDOM method being faster.
I don't know much about zio - I have been using akka to tell the truth, but that won't work that well on the client :-)
I need to try out one library to get going. I was thinking of cats effects. We used scalaz in banana-rdf 8 years ago.
The choice of effects libs in Outwatch could be very useful.
bblfish
@bblfish:matrix.org
[m]
Btw. having your own diffing lib is a big +point as I'd like to not depend on FB tech, since we are building https://www.youtube.com/watch?v=lgu8NUm5Zxk
bblfish
@bblfish:matrix.org
[m]
to build Solid apps we need the client to make a lot of requests around the web, and update the UI as new information becomes available.
bblfish
@bblfish:matrix.org
[m]
btw, are there any good talks on using scala http libs and effect systems in the browser to fetch resources etc...? I can't find much out there.
bblfish
@bblfish:matrix.org
[m]
I could not find outwatch on maven central. The doc says to use the latest commit. Is that some part of sbt that I don't know that compiles stuff from github?
  "com.github.outwatch.outwatch" %%% "outwatch" % "e02749756fdb3bad7fb92250ed8a2bfab0f69ea7"
I see we have "https://jitpack.io"
bblfish
@bblfish:matrix.org
[m]
I am trying to upgrade the demo example to Scala 3. I tried this https://github.com/bblfish/SolidCtrlApp but without got the following error
[success] Total time: 1 s, completed 7 Nov 2021, 21:43:34
[error] [webpack-cli] Unable to load '@webpack-cli/serve' command
[error] [webpack-cli] TypeError: options.forEach is not a function
[error]     at WebpackCLI.makeCommand (/Volumes/Dev/Programming/Scala3/solidapp/target/scala-3.1.0/scalajs-bundler/main/node_modules/webpack-cli/lib/webpack-cli.js:108:21)
[error]     at ServeCommand.apply (/Volumes/Dev/Programming/Scala3/solidapp/target/scala-3.1.0/scalajs-bundler/main/node_modules/@webpack-cli/serve/lib/index.js:41:19)
bblfish
@bblfish:matrix.org
[m]
I guess it is not a problem with scala 3.x because going down to 2.13 I get the same problem. Perhaps the version of webpack...
johannes karoff
@cornerman
@bblfish:matrix.org Hmm, I also do not get it to work with webpack5 and the scalajs-bundler rc1. Somehow there is some incompatible version of webpack-cli and webpack-cli/serve, with that version configuration.
Do you need webpack 5 for a specific reason?
bblfish
@bblfish:matrix.org
[m]
No, I was just trying to get the latest.
I found this https://youtrack.jetbrains.com/issue/KT-49124
But I think I am using 4.9.1
I am a bit slow because I don't really know the JS ecosystem tools
johannes karoff
@cornerman
If I force the deps webpack-cli -> 4.9.1 and @webpack-cli/serve -> 1.6.0, I get another runtime error:
[error] [webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
[error]  - options has an unknown property 'inline'. These properties are valid:
[error]    object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, static?, watchFiles?, webSocketServer? }
Something is incompatible there. Hmm.
I am still using webpack 4 in my projects without a problem. But might be worth asking in the scalajs-bundler channels.
bblfish
@bblfish:matrix.org
[m]
do you have a public git repo with a config that is working? (idally for scala3)
I don't really need the latest right now, I just need to get going :-)
bblfish
@bblfish:matrix.org
[m]
I'll got back to the seed.g8
johannes karoff
@cornerman

@bblfish:matrix.org Regarding the question about subscriptions and comparison to laminar.

Laminar uses their own streaming library called airstream, which has a really nice concept about reactive state management. There each operation that might lead to a subscription needs an implicit Owner. This owner then handles the subscription - i.e. is responsible for killing it. Using this in laminar, the owner is the enclosing html element. Airstream is in some ways similar to scala-rx, both fixing frp-glitches and using an Owner concept.

In outwatch we try to abstract over different streaming libraries, and not all have this owner concept. The subscription methods there, do not require an Owner, but instead return a Cancelable - a token to cancel the subscription. As long as it is handled, everything is fine.
Now as long as you do not call subscribe on Observables yourself (in colibri or monix), but just use them in outwatch components, everything is fine and subscriptions will be automatically cleaned up.
The only way to leak here, is to call subscribe yourself and actively ignore the returned subscription, like val _ = observable.subscribe(observer). You can still let outwatch handle the subscription manually with managed(SyncIO(observable.subscribe(observer)) inside a component - which imho is rarely needed. Normally, you just use an observable in your component and get everything handled automatically.

Also, if you use scala-rx directly - even with outwatch - the mentioned danger does not apply. Additionally, we should be able to support airstream with outwatch as well.
The seed should work. I have not used scala-3 with outwatch yet, so please let me know of any blockers you might find!
bblfish
@bblfish:matrix.org
[m]

Things start working when I move from

addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.0-RC1")

down to

addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler"  % "0.20.0")

in the plugins

Indeed the little app now works.
bblfish
@bblfish:matrix.org
[m]
It even works with scala 3.1.0 then . I pushed those changes to the https://github.com/bblfish/SolidCtrlApp
johannes karoff
@cornerman
Awesome!
We should start cross-compiling for scala 3 i guess :)
1 reply
bblfish
@bblfish:matrix.org
[m]
I found a nice intro to fs2 and cats effects for UI development. https://twitter.com/bblfish/status/1457992937804124166
That one writes directly to the dom interestingly enough, but is otherwise very FP. Is there any larger project one can look at with a lot of IO that uses OutWatch?
bblfish
@bblfish:matrix.org
[m]
Actually I went off to study cats-effect and co, but I am not sure if you work with cats-effect, and so http4s.
At least I could not find any references in the build file.
bblfish
@bblfish:matrix.org
[m]
(well it says you use cats-effect on the front page, but I guess it must be imported into the project in some indirect way)
bblfish
@bblfish:matrix.org
[m]
Ah cool the sbt dependencyTree tells me it is colibri that colibri that imports it.... (nice tool)
bblfish
@bblfish:matrix.org
[m]
ok, so I guess the latest http4s-dom uses cats-effects 3.x whereas colibri is using 2.6.1
moritz bust
@busti

@bblfish:matrix.org afaik technically projects that directly use a library should define it in their sbt file rather than relying on it through other dependencies. We should probably do that.

http4s-dom looks nice. I was wondering when they would ship their http client to js.

bblfish
@bblfish:matrix.org
[m]
they just release http4s-dom 1.0.0-M29 btw.
moritz bust
@busti
Studying cat's effect is a nice idea in general. The typelevel style in general is used in a big portion of scala libs and it's good to know what you're looking at when encountering libraries or code using the style.
I personally only use a single websocket connection in my project, but if I ever need to talk to a rest api it's probably a good choice
bblfish
@bblfish:matrix.org
[m]
For The Solid Project we write apps for the web thought of as one giant hyper-data RESTful system. Clients follow links from one server (Pod) to another to build up UI elements. So even though websockets are also used, we really need streaming http libraries.
bblfish
@bblfish:matrix.org
[m]
I have written my server in Akka but I think having akka on the client would be a bit heavy on the client. So that means I need to learn another set of libraries on this. Cats-effect seemed indeed like a good thing to try out, and as you say it is widely used...
elyphas
@elyphas
I have some kind of problem when I use onInput the focus on element input is loss more or less, because the element is showing is focused but the cursor is loss.
this happens on chrome but not on firefox.
I was searching for some solutions on google but I have some Observer connecting on this element so I don't quite get the solution.
Any idea please. :-)
this my code:
  val onChangingValueTxt =
        SyncIO(
          onInput
             .value
             .transformLifted( (e: Observable[String]) =>
               e
               .distinctUntilChanged
               .withLatestFrom(hdlFieldActive){ case (txt: String, (field: String, currentValue: JsonValue)) =>
                    val currentValue2: JsonValue = Try {
                            wrapValue(txt, currentValue)
                    } match {
                            case Success(value) => value
                            case Failure(exception) => JsonNull
                    }

                  (field, currentValue2)
                }
             ) --> hdlChangingValue
        )
elyphas
@elyphas
making a filter( x => x.length > 5) loses the cursor after 5 keys
elyphas
@elyphas
I found the problem all of that is inside the Try block:
    val mountCellFocusSelectContent = Observer.create[(dom.Element, String, String)] { case (elem, inputType, idTxt) =>
        if (idTxt == elem.id) {
                val txt = if ( inputType == "input" ) elem.asInstanceOf[html.Input] else elem.asInstanceOf[html.TextArea]
                Try {
                    val range = dom.document.createRange
                    val sel = scalajs.dom.window.getSelection
                    sel.removeAllRanges
                    range.selectNodeContents(txt)
                    sel.addRange(range)
                } match {
                    case Success(value) =>
                        txt.focus
                    case Failure(exception) => alert("Hubo un error al convertir el valor del componente: line:102 from Grid3 " + exception.getMessage())
                }
        }
    }
the solution seems is this:
$('#Search').focus(function() {
    setTimeout((function(el) {
        var strLength = el.value.length;
        return function() {
            if(el.setSelectionRange !== undefined) {
                el.setSelectionRange(strLength, strLength);
            } else {
                $(el).val(el.value);
            }
    }}(this)), 0);
});
What would be the correct translation to Outwatch ?