Skip to content

v2.1

Latest
Compare
Choose a tag to compare
@osipxd osipxd released this 06 May 05:59
· 2 commits to main since this release
714ed91

Reusable properties

Reusable properties introduced to address the problem described in issue #14

Reusable properties survive MapMemory.clear() call. It will not be removed from cache, but will be cleared instead. Reusable properties are especially useful for reactive types like Flow. You don't need to resubscribe to flow after MapMemory was cleared.

val flow by memory.sharedFlow<Int>()

// Subscribe to flow
flow.onEach(::println).launchIn(coroutineScope)
// And then clear MapMemory
memory.crear()

// Emitted value will be printed because the flow
// is the same as before memory clear
flow.emit(1)

You can create reusable property using operator invoke with clear lambda:

class Counter {
    fun reset() = { /*...*/ }
}

val counter: Counter by memory(clear = { it.reset() }) { Counter() }

Many of default accessors are already turned into reusable: mutableList, mutableMap, reactiveMutableMap, stateFlow, sharedFlow, behaviorSubject, publishSubject.

Changes

  • ⚠️ Deprecated functions removed: MapMemory.nullable, MapMemory.reactiveMap, ReactiveMutableMap.getStream, ReactiveMutableMap.getAll, ReactiveMutableMap.getAllStream
  • Added parameter defaultValue to most of reusable properties: mutableList, mutableMap, reactiveMutableMap, behaviorSubject.
  • ⚠️ mapmemory-rxjava: ReplayStrategy was removed. Please let us know if this change affected you: #20

Fixes

  • ReactiveMutableMap: initial empty map is not emitted (#15)

Dependencies

  • mapmemory: Kotlin 1.4.301.8.20
  • mapmemory-coroutines: kotlinx.coroutines 1.4.21.6.4
  • mapmemory-rxjava3: RxJava 3.0.113.1.6

Housekeeping

  • infrastructure 0.8.20.18.1
  • detekt 1.16.01.22.0
  • Gradle 6.8.38.1.1
  • binary-compatibility-validator 0.5.00.13.1

Full Changelog: v2.0...v2.1