This message was deleted.
# plugin-development
s
This message was deleted.
v
Exactly what their names say.
Copy code
interface 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"))
=>
Copy code
all 1
all 2
added 2
k
I was having trouble with an
addAllLater()
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.
v
Well, what should I say, hard to guess without the actual code.
Copy code
interface 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")) })
=>
Copy code
all 0
all 1
all 2
added 2
all 3
added 3
Actually,
addAllLater
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.
k
I was having an issue where there was nothing that was realizing the objects being added, so my container was saying that my objects were not registered because the one provider that added them all was never realized.
v
Yeah, that can happen. Even happened in Gradle core iirc.
k
I blame it on the fact that there is still a wide gap in understanding between, say, a
ListProperty
and
DomainObjectList
.