Slackbot
09/27/2023, 8:47 PMVampire
09/27/2023, 10:23 PMVampire
09/27/2023, 10:23 PMinterface Foo : Named
val foo = objects.domainObjectContainer(Foo::class)
foo.add(objects.named("1"))
foo.all { println("all $this") }
foo.whenObjectAdded { println("added $this") }
foo.add(objects.named("2"))
=>
all 1
all 2
added 2Kelvin Chung
09/27/2023, 10:28 PMaddAllLater() on a DomainObjectCollection<String>, where I put in an all block that registered objects in a NamedDomainObjectContainer. And wondering why the objects I was expecting to have been registered, weren't registered.Vampire
09/27/2023, 10:35 PMVampire
09/27/2023, 10:35 PMinterface Foo : Named
val foo = objects.domainObjectContainer(Foo::class)
foo.addAllLater(providers.provider { listOf(objects.named("0")) })
foo.add(objects.named("1"))
foo.all { println("all $this") }
foo.whenObjectAdded { println("added $this") }
foo.add(objects.named("2"))
foo.addAllLater(providers.provider { listOf(objects.named("3")) })
=>
all 0
all 1
all 2
added 2
all 3
added 3Vampire
09/27/2023, 10:37 PMaddAllLater can be slightly misleading, because the provided value is not added later.
It is added immediately, but only realized later (when needed).
Using whenObjectAdded will not see it in any case if addAllLater was called before.Kelvin Chung
09/27/2023, 10:39 PMVampire
09/27/2023, 10:44 PMKelvin Chung
09/27/2023, 10:48 PMListProperty and DomainObjectList.