All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.raven.LocalOutbox.kt Maven / Gradle / Ivy

There is a newer version: 3.0.11
Show newest version
package raven

import koncurrent.Later
import koncurrent.later.then
import koncurrent.toLater

class LocalOutbox

( private val capacity: Int = DEFAULT_CAPACITY, private val isSent: P.(to: String) -> Boolean ) : Outbox

{ companion object { val DEFAULT_CAPACITY = 10 } private val messages = mutableListOf

() override fun store(params: P): Later

{ if (messages.size > capacity) { messages.removeFirst() } messages.add(params) return params.toLater() } override fun sent(to: String) = messages.filter { it.isSent(to) }.toLater() override fun delete(receiver: String) = sent(to = receiver).then { messages -= it it } override fun toString() = "LocalOutbox(capacity = $capacity)" }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy