I've encountered some annyoances when using KotlinX Coroutines, and so I've decided to move my own scattered-around solutions into the library itself.
The functions to create empty collections/maps are named inconsistently with the stdlib; persistentXxxOf instead of emptyXxx.
There are no functions to create persistent and immutable maps from sequences, arrays, and iterables of pairs. The only options are to call list.toMap().toImmutableMap() or persistentMapOf<Xxx>().mutate { addAll(list) }.
Replacing immutableXxxOf with persistentXxxOf results in bugged code, as the type parameter is ignored.
The library didn't build at all on my Linux laptop. I have added some gradle properties to fix that.
Though I do have some questions:
Should error-deprecated emptyImmutableXxx() no-op functions be created, similarly to Flow.forEach { }?
Should the .toImmutableMap() functions be removed or error-deprecated? As far as I understand, Map.toImmutableMap is kept as it returns the receiver if it is an instance of ImmutableMap; But the new functions simply call their persistent versions.
As a side-note, should kotlin-js-store/yarn.lock be added to the .gitignore, or should it be committed?
Sorry for the big PR; Lots of the changes I did were in the same file and some even in the same lines, so it made more sense to submit them together than separately.
I've encountered some annyoances when using KotlinX Coroutines, and so I've decided to move my own scattered-around solutions into the library itself.
persistentXxxOf
instead ofemptyXxx
.list.toMap().toImmutableMap()
orpersistentMapOf<Xxx>().mutate { addAll(list) }
.immutableXxxOf
withpersistentXxxOf
results in bugged code, as the type parameter is ignored.Though I do have some questions:
emptyImmutableXxx()
no-op functions be created, similarly toFlow.forEach { }
?.toImmutableMap()
functions be removed or error-deprecated? As far as I understand,Map.toImmutableMap
is kept as it returns the receiver if it is an instance ofImmutableMap
; But the new functions simply call their persistent versions.kotlin-js-store/yarn.lock
be added to the.gitignore
, or should it be committed?Sorry for the big PR; Lots of the changes I did were in the same file and some even in the same lines, so it made more sense to submit them together than separately.