These are chat archives for ThoughtWorksInc/Binding.scala

27th
Jul 2017
杨博 (Yang Bo)
@Atry
Jul 27 2017 01:26
@kahliburke Would you mind asking the question on StackOverflow instead?
Or create an issue here if it seems like a bug
Kahli Burke
@kahliburke
Jul 27 2017 03:06
Sure, I did find a workaround having to do with the ordering of bind statements. I'm happy to do stackoverflow too but sometimes the quicker back and forth can be helpful in forming a more succinct question which is why I checked in here. I'm trying to learn the correct patterns to apply with your library and where the rough spots might be. My main points of confusion have been around use of closures, and needing to create a temp variable outside the closure where I can call bind which I can then reference in the closure. That and ordering of operations like the
example I posted.
杨博 (Yang Bo)
@Atry
Jul 27 2017 03:10
Have you tried to change some vals of Bindings to defs? It seems a little dangerous if vals are shared between different conditions.
Kahli Burke
@kahliburke
Jul 27 2017 03:49
Interesting, I've been doing mostly vals because I thought they could be shared. I will experiment with defs
Kahli Burke
@kahliburke
Jul 27 2017 03:55
Would you say that it's safe to share Var and Vars between different downstream values or methods?
Kahli Burke
@kahliburke
Jul 27 2017 04:20
Changing things to def instead of val does fix the issue I was having as well. There are lots of val in the ScalaFiddle examples online, so I'll have to learn more about what the circumstances are that preclude using them. Thank you for the suggestion.
杨博 (Yang Bo)
@Atry
Jul 27 2017 04:21
Vars are usually shared, of course
Kahli Burke
@kahliburke
Jul 27 2017 04:22
Would you say that it's always correct/best to use def for a Binding[T]
If I understand the rules I'd be happy to put in a pull request with some documentation updates.
Would it be best to prevent the macro from applying to val?
Also I see that there is some upcoming discussion about @html macro/annotation but I'm not sure what the goals were, what you were trying to move away from.
杨博 (Yang Bo)
@Atry
Jul 27 2017 04:28
I did not understand the cause of the behavor of your fiddle. The def suggestion is just my guess.
It would help if there is a minimized version that demostrates the difference between def and val.
I'm not sure if the difference between def and val is a bug.
It should be fixed if it is a bug instead of forbidding the usage of val.
Kahli Burke
@kahliburke
Jul 27 2017 04:33
I was going to put up another fiddle but it seems to be broken for me right now (nothing will compile). I will put up a more minimal example if possible and show what works and what doesn't, if that would be helpful. I appreciate you taking the time to answer these questions, I'll post on here with some urls tomorrow.
杨博 (Yang Bo)
@Atry
Jul 27 2017 04:35
Thank you! That would definitely help.
Kahli Burke
@kahliburke
Jul 27 2017 18:54
ScalaFiddle author fixed it for me, I've put up this example which I hope is minimal enough to be useful. It displays the 'working' and 'not working' situation, which differs only in the choice of a Binding being def vs val. To demonstrate, click the checkbox, you should see 10 numbers below each piece of text. Then uncheck, change the number of elements to say 2, and then check box again. You'll see that the 'working' section displays 2 numbers while the 'not working' section displays 10 still. However if you change the number while the checkbox is checked, both sections have the same behavior (NOTE you must blur the input, it's not responding to key events, just onchange). If you think it's a bug and want it entered into github issues, let me know. Thanks!