Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 21 04:46
    scala-steward opened #260
  • Feb 16 04:27
    scala-steward opened #259
  • Feb 15 09:45
    scala-steward opened #258
  • Feb 10 22:17
    scala-steward opened #257
  • Feb 03 23:27
    scala-steward opened #256
  • Jan 24 19:12
    scala-steward opened #255
  • Jan 23 20:20
    scala-steward opened #254
  • Jan 16 18:58
    scala-steward opened #253
  • Jan 07 16:20
    Atry closed #252
  • Jan 07 16:20
    Atry commented #252
  • Jan 07 09:27
    jilen opened #252
  • Jan 01 02:28

    Atry on master

    Update README.md (compare)

  • Dec 30 2019 04:22

    Atry on master

    Update README.md (compare)

  • Dec 30 2019 04:15
    Atry closed #175
  • Dec 30 2019 03:52
    Atry commented #175
  • Dec 30 2019 03:52
    Atry commented #175
  • Dec 30 2019 03:51
    Atry commented #175
  • Dec 30 2019 03:48
    Atry commented #175
  • Dec 30 2019 03:46
    Atry edited #175
  • Dec 30 2019 03:46
    Atry edited #175
JohnZorn
@nakedcity
I dont mind to switch to anything that does some state management I was even thinking about https://github.com/suzaku-io/diode
when it comes to redux the only that I really like of it is the dev tools which I have found very handy for following the state of the app
I was just asking what is the common practice when you work with Scala.Binding
杨博 (Yang Bo)
@Atry
There is a DEMO that demonstrates how to build a center state tree similar to Redux https://scalafiddle.io/sf/o5fWdS3/3
Note that subview1 and subview2 accept Binding as parameters instead of raw values, in order to partially rendering subviews that when only parts of store are changed.
In the above example, there is only one Var used in the entire application.
Mustafa Kuscu
@mcku
@nakedcity I also switched from a react+redux app to binding.scala. For keeping alignment with the old project, I am maintaining an actions.scala and a reducers.scala. I think the type safe copy (which @atry mentioned the demo) is the killer feature (would it be a bold statement to claim that it is something JS/TS world never had?) and can implement redux very easily. and you don't code on the overly-async javascript, instead scala and execution order is not an issue afaik (once upon a time I was banging my head with promise chains). Then the redux is not necessary because the state is already there in a stable manner. In JS world keeping a global state would be very unstable and would be hard to detect and reason on who modifies what. But simply you don't have such language-originated deficiencies in ScalaJs. That's a summary of my overall impression so far.
The redux middlewares have changed multiple times within the last 2 years. There was redux-thunk 2 years ago now they have some other thing (I can't remember). Now if you start you completely start with a different paradigm, and I don't expect a stable approach to develop there in the short or middle term.
JohnZorn
@nakedcity
Thanks for all the answers but still the question is what are you guys normally using diode, raw objects? I dont care about redux
Leonid Turnaev
@glmars
Yes. I used. Diode is the same as React (+ TypeScript :smile: ), only difference is Scala language.
Leonid Turnaev
@glmars

@mcku

Using MutationObserver, I am able to use jQuery based semantic-ui components without rewriting them in binding.scala from scratch

Could you check something like this: https://gist.github.com/glmars/a597f7c28931a38e2e9b3262279889a9 ?
The main ideas are using Element based selector in jQuery instead of string based and initializing of control right after creation.

Leonid Turnaev
@glmars
And if I my guess is correct you are using outdated jQuery facade (https://github.com/sjrd/scala-js-jquery)
There is new one: https://github.com/jducoeur/jquery-facade
Mustafa Kuscu
@mcku
I agree. I should admit that I never wanted to enter the jQuery zone. Because there already existed a separate semantic-ui project called stardust, which avoids jQuery completely. It is possible to inspire from that (which i did, too) and rewrite the components, as they did for the stardust. (http://react.semantic-ui.com, and for the dropdown, https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Dropdown/Dropdown.js ) But the rewrite can be an exhaustive task.
But the problem with the jQuery part is it only answers to queries after the element is on the dom. Therefore in a binding method, the element is still not mounted on the actual dom, if i understand it correctly. Nevertheless, i did not know this before and i have tried what you have suggested some time ago, and did not work and this is the conclusion i got after inspecting at the browser debugger.
Mustafa Kuscu
@mcku
There is also the udash jQuery facade. I was using that until i discovered that it was including a bootstrap dropdown (but later i partially realized that it was coming from udash-bootstrap), therefore removed it.
Mustafa Kuscu
@mcku
btw, i am using udash i18n for migrating existing translations from lingui. but modified it a little bit, so that {t("hello").bind} gives the correct translation. The idea came from here: https://lingui.js.org/tutorials/react-patterns.html#id1 and i think it is good, and that idea can be ported to scalajs
i think part of the work would be to write a sbt plugin that includes a macro to preprocess the code and extract messages, (lingui js uses babel for that), and a translating function that can utilize udash's translation provider and combining that with binding.scala. the result is very efficient and readable.
but i don't have the plugin yet. just the idea and a similar concept for the plugin of scalingua (https://github.com/makkarpov/scalingua) unfortunately i could not make it work in scalajs
Mustafa Kuscu
@mcku
for the udash translation wrapper, most of it is here https://gist.github.com/mcku/dd71065a93bf409e8688e75734fde6ce
JohnZorn
@nakedcity
@glmars dude do you have some example of integreation with diode?
Leonid Turnaev
@glmars
Integration with what? We didn't use diode with Binding.scala, before we switched to Binding.scala completely our stack was diode+scalajs-react.
Leonid Turnaev
@glmars
@mcku "i have tried what you have suggested some time ago, and did not work" Are you sure what problem was in initialization and not in missing watch/render/bind or something like this? In our case initialization after creation works well with https://getmdl.io/ and https://materializecss.com
杨博 (Yang Bo)
@Atry
@mcku Your example for translation is impressive!
JohnZorn
@nakedcity
@glmars do you have an example of your current setup? I want to see how is your architecture specially for Vos
JohnZorn
@nakedcity
Do you guys know some project like storybook or cosmos that you can easily plug-in with Binding-scala
Leonid Turnaev
@glmars
Sorry, I couldn't post a full project. Could you ask something more concrete? Which aspect are you interested in? What does "Vos" mean?
JohnZorn
@nakedcity
Value Objects
I still find really handy Leonid to have one state than a bunch of objects across the app
but maybe I’m not seeing clear the approach that you have
for example in this example
data has to be passed which I dont think it’s easy to manage in big projects
Leonid Turnaev
@glmars
Before Redux like comes in, there was a lot of projects without single state and without any problems :smirk: For example on desktop.
JohnZorn
@nakedcity
I have been working in programing for 20 years I know that but that no changes the fact that the pattern of having a store where you can select just partitions is more manageble than having to control a bunch of raw objects which as you mention was the main cause in the past of memory leaks
Leonid Turnaev
@glmars
Hmm I said nothing about memory leaks. In my opinion, if I have a problem, I will try to find a solution, but I don't have a problem with state about 20 years of my programming career :smile: If you have a problem you can try a single state paradigm of course :smirk:
JohnZorn
@nakedcity
Hahaha nice answer thanks for all the input :)
I get back to my atari now since that one was also working fine :)
Leonid Turnaev
@glmars
Nice joke :smile: :+1:
Mustafa Kuscu
@mcku

@mcku "i have tried what you have suggested some time ago, and did not work" Are you sure what problem was in initialization and not in missing watch/render/bind or something like this? In our case initialization after creation works well with https://getmdl.io/ and https://materializecss.com

@glmars I think my conclusion is wrong and jQuery can access the element. And your proposal is very elegant and valuable.
However, it's not done yet. dom.scala thinks it is inserting the element twice and throws an exception. But by tracing, i can confirm that the method is entered just once.
The element is here https://gist.github.com/glmars/a597f7c28931a38e2e9b3262279889a9#file-dropdown-initialize-scala-L17
And here is the exception: https://github.com/ThoughtWorksInc/Binding.scala/blob/v11.3.0/dom/src/main/scala/com/thoughtworks/binding/dom.scala#L106

message is: "Cannot insert SELECT twice!"

Any ideas? I have traced through debugger and it enters only once into the JQuery call. And there is only one jquery instance, as seen by the inspector.
Mustafa Kuscu
@mcku
Oh.. i think the example happened to be a corner case. because the <select>...</select> was being transformed into a <div>...</div> by jquery on the fly. and perhaps this is confusing the internals of binding.dom.
Mustafa Kuscu
@mcku

and it is successful if the element is not initially specified as a select and dynamically contructed, instead if specified as something already html div like this (which is as legit as the previous one)

val simple = <div class="ui selection dropdown">
  <input type="hidden" name="gender"/>
  <i class="dropdown icon"></i>
  <div class="default text">Gender</div>
  <div class="menu">
    <div class="item" data-value="1">Male</div>
    <div class="item" data-value="0">Female</div>
  </div>
</div>

yay, it works ;)

Leonid Turnaev
@glmars
Glad to hear. :+1:
Restart my project
Darcy Shen
@sadhen
@mcku Where is stardust?
I'm wondering if my work is useful for you.
However, I'm not front-end developer. Just for fun!
Wojtek Pituła
@Krever
I was thinking about developing a Binding subclass supporting async fetching based on cats effect. So you would give a F[T] and get binding with pending/failure/success distinction. Is there anything like that already?