Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 18 08:52

    ddworak on master

    Update scala-logging to 3.9.4 Merge pull request #816 from sc… (compare)

  • Jun 18 08:52
    ddworak closed #816
  • Jun 17 13:12
    scala-steward opened #817
  • Jun 16 15:38
    scala-steward opened #816
  • Jun 16 06:42

    ddworak on master

    Update momentjs to 2.29.1 Merge pull request #716 from sc… (compare)

  • Jun 16 06:42
    ddworak closed #716
  • Jun 16 06:36

    ddworak on scala-library-2.13.6

    (compare)

  • Jun 16 06:36

    ddworak on master

    Update scala-library, scala-ref… Merge branch 'master' into upda… Update scala-library, scala-ref… and 3 more (compare)

  • Jun 16 06:36
    ddworak closed #815
  • Jun 15 14:29
    ddworak review_requested #815
  • Jun 15 14:17
    ddworak closed #795
  • Jun 15 14:17
    ddworak commented #795
  • Jun 15 14:17
    ddworak opened #815
  • Jun 15 14:17

    ddworak on scala-library-2.13.6

    Update scala-library, scala-ref… Merge branch 'master' into upda… Update scala-library, scala-ref… and 2 more (compare)

  • Jun 15 11:54
    ddworak closed #811
  • Jun 15 11:54

    ddworak on master

    Update sbt to 1.5.4 Merge pull request #813 from sc… (compare)

  • Jun 15 11:54
    ddworak closed #813
  • Jun 15 11:54
    ddworak closed #812
  • Jun 15 11:53

    ddworak on master

    Update commons-analyzer, common… Merge pull request #814 from sc… (compare)

  • Jun 15 11:53
    ddworak closed #814
Kirill A. Korinsky
@catap
As far as I see the easy way it introduce excetion and add handler to application.onRoutingFailure; but it is a bit wired, isn't it?
Kirill A. Korinsky
@catap
@ddworak and second question (I feel that it is similar things): how can I implement /logout url?
Dawid Dworak
@ddworak
Let me start with answering the second one then - I'd just usually just stick a button in the RootView and on the click callback just:
      userContextService.logout() //basically whatever you do to keep context
      application.goTo(LoginPageState)
For the first question, you can call application.goTo anywhere basically. There are no limits, once the app is initialized and you can get a handle on the reference, the sky is the limit ;) Whether it's a presenter, a button click handler, static code - doesn't matter at all.
Kirill A. Korinsky
@catap

@ddworak I did the same things about logout. Before I thougt to add /logout URL but I realised that it makes things just more complicated.

Regarding routing: I doubt that application.goTo inside matchUrl is good idea, but, again, throw an exeception here is more than fine for now. So, please ignore this.

Kirill A. Korinsky
@catap

@ddworak about #656: I have to try to work with big file (100mb and bigger) and noticed some issue.

Because I'm overload on another topics, I can't finish it right now => requires some time

But, if you have a loock to the code I will be appricieted

Kirill A. Korinsky
@catap
This message was deleted
Dawid Dworak
@ddworak
@catap will do when I can :) thanks for helping out
Kirill A. Korinsky
@catap

@ddworak about #664 and why I did it. I tried to use FileInput.single and I don't understand how.

I feel that it is a typo and it should be implemeted via Option[File] and my code right now use the same technic.

But, probably, I've missed something (how to use it). If no => I can open a PR to change API of FileInput.single

Dawid Dworak
@ddworak
I'm not sure, but I'll analyze the usage patterns in our internal codebase once I get to the property issue.
Kirill A. Korinsky
@catap
Thanks!
Kirill A. Korinsky
@catap

@ddworak Hey! I marked as ready for review UdashFramework/udash-core#656

It contains a bit more code and I'd like to hear your thoughts about this.

Dawid Dworak
@ddworak
@catap cool, I'll try to take a look this week :) thanks!
Kirill A. Korinsky
@catap
@ddworak any news?
Dawid Dworak
@ddworak
@catap sorry for the delay, we had more pressing matters to solve this week with scalamock not working on SJS and a bug in the view renderer - let's hope for a better one
Kirill A. Korinsky
@catap
:)
Thanks, I just would like to merge it somehow in the next release
Kirill A. Korinsky
@catap
@ddworak thanks. I try to do it this week
Dawid Dworak
@ddworak
@catap no problem, sorry for taking so long. Let's keep it simple so it can get merged easily :)
Kirill A. Korinsky
@catap
@ddworak I hope you can answer a few question soon
Gerald Mixa
@gmixa
Hello is there a migration concept somewhere from udash 0.8 to 0.9 or an running example App for 0.9 ?
Dawid Dworak
@ddworak
@gmixa hey, this will get published when we finally release 0.9, high time I guess ;) please ask here if you need any help, we'll be happy to
Gerald Mixa
@gmixa

i tried to adapt the g.8 generated example for 8.0 to 0.9-M4. things that i did not manage to fix are:

the multi language support (it seems 0.9 does not support setting a current lang) - theres no set method anymore
registration of model validation seems to have changed from handmade to macros? i have no clue how to transform these so that they are working again. If anybody is interested i could put what i have done so far on github so that somone else might be able to check the changes!
I have taken out all non existing dependencies. The Backend part seems to compile and pass tests. The changes in frontend are not that obvious to me that i could resolve them on my own!

Kirill A. Korinsky
@catap
@gmixa you can put your question here. I've migrated g.8 from 0.8 to 0.9; it was a bit strange but I managed it
Dawid Dworak
@ddworak
@gmixa no significant features were removed, I'll take my shot at migrating a template-generated project and let you know how it went
Dawid Dworak
@ddworak
@gmixa this would be the migration of the default (template) project ddworak/udash-0.9-migration@1e696fa
Kirill A. Korinsky
@catap
@ddworak my guess is removing model validation is confised @gmixa
Gerald Mixa
@gmixa
@ddworak seems i did not get that i just can delete some parts
Kirill A. Korinsky
@catap
@gmixa it also confused me a lot
Des
@hughgearse

Hi
Say I have defined the following model

case class Model(name: String, address: String)
object Model extends HasModelPropertyCreator[Model]

And then I combine two of the model properties and listen thus:

val profile = model.subProp(_.name).combine(model.subProp(_.address) {  case (name, address) =>
  s"$name, $address"
}
profile.listen { profile =>
  println("Profile updated: " + profile)
}

Now when I go to update the model by doing the following:

model.subProp(_.name).set("Some Name")
model.subProp(_.address).set("Some Address)

I find my profile listener is getting invoked twice. Once when I set the name and again when I set the address. Is this the expected behavior and if so is there a way I can avoid this double invocation?
Thanks, Des

Dawid Dworak
@ddworak
@hughgearse it is expected but avoidable when that's your intention.
  1. If you know you're changing the whole model, you can just do model.set(...).
  2. When you want to change a couple of subproperties without replacing the whole model and suppress updates until they're all set, you can use io.udash.properties.CallbackSequencer.
    CallbackSequencer().sequence {
    model.subProp(_.name).set("Some Name")
    model.subProp(_.address).set("Some Address)
    }
Des
@hughgearse
Excellent tx, that worked. Yes my scenario would be the second one - the example was just to demonstrate. I know I have been advised on this forum in the past not to change the whole model when only changing some properties as it could cause unexpected listeners to be fired
Des
@hughgearse

Hello Again
I have an issue where if I bind a property to an input and then set the property value, the displayed value does not change:

    val prop = Property("")

    def getTemplate: Modifier =
        div(
            input(value.bind(prop)),
            button(onclick := { () => prop.set("Pressed")}, "Press")
        )

When I open the page and click the button the input changes fine. But once I manually modify the text in the input box and then click the button it will no longer change. Strangely, when I examine the input element using the Firefox Inspector I can see that the value attribute of the input does get changed. But the displayed value does not
Am I doing something wrong?

Dawid Dworak
@ddworak
@hughgearse it works as expected. You're only providing an initial value element to the input, but native inputs replace it (the binding) whenever you type something inside. You need an input which supports bidirectional binding (e.g. io.udash.TextInput) I think there are examples in the Udash Guide, but I've checked your example and it also works fine with it: https://scalafiddle.io/sf/OwoCpVJ/0
Des
@hughgearse
Great tx
Des
@hughgearse

I have a scenario where I need to create a property based on a combination of two other properties - one readable and one writable:

val propA: ReadableProperty[A]
val probB: Property[B]

val propC: Property[C]  // based on propA and propB

Changes to propA need to be immediately reflected in propC and changes to propC will affect changes to propB. I am guessing there is no approach possible using combine and transform?
Is my only option to create a new propC from scratch based on the current state of propA and propB. Then I would need to listen for changes to propA and propC and update the corresponding property?

Dawid Dworak
@ddworak
@hughgearse what do you mean by changes to propC will affect changes to propB? Is there some sort of a cycle? Can you give an example?
Des
@hughgearse

Hi @ddworak. Lets say I've defined the following two properties:

    var propA: ReadableSeqProperty[(Int, String)]    // set of non-unique id/string pairings that is constantly updated
    var propB: Property[Set[Int]]    // a set of unique ids that are of interest to us - empty set meaning all ids

And I want to provide a property to allow a display/update of which unique ids we are interested in - displayed in a drop-down selection box. The unique set of ids for this property, propC are inferred from propA. End the end I came up with the following solution:

    val propC = SeqProperty[(Int, String, Boolean)] {
        propA.get.toSet.filter(a => propB.get.isEmpty || propB.get.contains(a._1))
            .map(a => (a._1, a._2, true)).toSeq.sortBy(_._2)
    }

    propA.listenStructure { case Patch(_, removed, added, _) =>
        removed.map(_.get).foreach { case (id, name) =>
            if (! propA.get.exists(_._1 == id) )
                propC.remove(propC.get.indexWhere(_._1 == id), 1)
        }
        added.map(_.get).foreach { case (id, name) =>
            if (!propC.get.exists(_._1 == id)) {
                val idx = propC.get.indexWhere(_._2 > name)
                propC.insert(if (idx < 0) propC.length else idx, (id, name, true))
            }
        }
    }
    propC.listen(cs => propB.set(cs.filter(_._3).map(_._1).toSet))

My first instinct was to do a combine of propA and propB and then do a transform to create propC. But I realised as I was doing it that it didn't make sense. So I was wondering if there might be a simpler solution than what I came up with?

Dawid Dworak
@ddworak

@hughgearse the code you ended up with really seems complex. I'd start with a simple:

  val all: ReadableSeqProperty[(Int, String)] = SeqProperty(1 -> "a", 2 -> "b")
  val interesting: SeqProperty[(Int, String, Boolean)] = SeqProperty.blank
  all.transformElements { case (id, str) => (id, str, false) }.streamTo(interesting)(identity)

  val unique = interesting.transformToSeq { interesting =>
    val result = interesting.iterator.collect { case (_, str, true) => str}.toSeq
    if(result.isEmpty) all.get.map(_._2) else result
  }

You could also just maintain a set of selected values and easily filter by that if you don't need that intermediate property with a 3-tuple, but I guess that depends on your use case.

Des
@hughgearse
Perfect @ddworak the streamTomethod was my missing ingredient
Dawid Dworak
@ddworak
glad I could help :)
Des
@hughgearse

Hi. I am wondering what is the best way to choose between two similar ReadableSeqProperties based on the value of another property. So say I have the following:

trait A { val x: Int }
case class B(x: Int, y: Int) extends A
case class C(x: Int, z: Int) extends A

And instances of these are contained in two separate sequences:

val listB: ReadableSeqProperty[B] = ...
val listC: ReadableSeqProperty[C] = ...

I would then like to define a generic list that changes depending on another property:

val useB = Property(true)
val currentList: ReadableSeqProperty[A] = useB.transform { if (_) listB else listC }  // Something like this ???
Grzegorz Szeremeta
@mereszeta

Not sure if this couldn't have been done better based on the context, but straightforward approach could be something like:

val current = listB.combine(listC)((_, _)).combine(use) { case ((listB, listC), which) =>
  if (which) listB else listC
}.transformToSeq(identity)

.transformToSeq only needed if you need ReadableSeqProperty as a return type, this should create property that's updated after any change in listB, listC or use

Des
@hughgearse

That doesn't compile for me - the compiler sees listB as a single instance of B. But if I instead do:

val current = listB.asInstanceOf[ReadableProperty[Seq[B]]].combine(listC)((_, _)).combine(use) { case ((listB, listC), which) =>
  if (which) listB else listC
}.transformToSeq(identity)

It compiles fine. But I guess that's still correct?

Grzegorz Szeremeta
@mereszeta
My whole snippet for reference, works fine:
import io.udash._
trait A {
  val x: Int
}
case class B(x: Int, y: Int) extends A
case class C(x: Int, z: Int) extends A

val listB: ReadableSeqProperty[B] = Seq(B(1, 2), B(3, 4), B(5, 6)).toSeqProperty
val listC: ReadableSeqProperty[C] = Seq(C(9, 8), C(7, 6), C(5, 4)).toSeqProperty

val use = Property(true)

val current = listB.combine(listC)((_, _)).combine(use) { case ((listB, listC), which) =>
  if (which) listB else listC
}.transformToSeq(identity)

current.get.foreach(a => println(a.x))

use.set(false)


current.get.foreach(a => println(a.x))
Des
@hughgearse
That doesn't compile for me. Same issue as mentioned above. Using version 0.8.6
Des
@hughgearse

Hi
Given the following:

case class A(x: Int, y: Int)
case class B(propA: ReadableProperty[A])
val propA: Property[Option[A]]

Is there any way I can transform propA to produce a ReadableProperty[Option[B]]?

Bartłomiej Grochal
@bgrochal

Hello, @hughgearse!

The most straightforward way is just to transform the original Property:

val propB: ReadableProperty[Option[B]] = propA.transform(_.map(a => B(a.toProperty)))

However it's usually suspicious to hold a Property (B#propA in this case) within another Property (propB), especially when both Properties are expected to be readable. Maybe you need B to hold plain value of A and propB to be a ModelProperty:

case class A(x: Int, y: Int)

case class B(a: Option[A])
object B extends HasModelPropertyCreator[B] {
  implicit val blank: Blank[B] = Blank.Simple(B(None))
}

val propA: Property[Option[A]] = Property(Some(A(0, 0)))
val propB: ModelProperty[B] = ModelProperty.blank
propA.streamTo(propB)(B(_))
Des
@hughgearse
Tx @bgrochal . Your suspicions were justified. The problem pointed to a flaw in my model, view, presenter separation and on closer inspection I was trying to implement some presenter functionality within my model logic. Once I moved that out there was no longer a need for the property
Bartłomiej Grochal
@bgrochal
Sounds great, glad I could help! :)