This message was deleted.
# plugin-development
s
This message was deleted.
v
Well, if you don't depend on the laziness, you can of course just use
.asMap
. But what is so problematic with
_container_._names_._associateWith_(_container_::named)
? You could even pack it into an extension function if you prefer:
fun <T> NamedDomainObjectCollection<T>.asLazyMap() = _names_._associateWith_(::named)
and then
container._asLazyMap_()
.
k
True, I wished it was part of the Kotlin API, that's all, and that I didn't have to roll it out myself.
v
Open a feature request or pull request for it 🙂
p
It would be nice if the map were live.
k
Wouldn't that be something that spits out
Provider<Map<String, T>>
instead?
v
Not necessarily. That would just mean it is lazily calculated. The provider could be caching to just calculate it the first time you request it, or it could calculate it each time you request it. But even with the latter, you can request it and just have a reference to the
Map
which wouldn't change. A live map like Philip means would always have the proper entries live. So if you get the map now, then add an entry to the container (or even remove one), the map would automatically have (or not have) the according entries.