Skip to content

Event Characteristics #10

@JonathanxD

Description

@JonathanxD

This is set to 1.9 milestone, but does not mean that will be delivered in 1.9 version, this is only a wip proposal.

Proposal

Support a sort of characteristics in events (or dynamic characteristics).

Example

Event:

interface AccountMoneyChangeEvent : Event {
    val amount: Int
}

Characteristic inclusion:

val accountMoneyChangeEvent = factory.accountMoneyChangeEvent(-5).characteristic(Bank.OPERATION, Operation.WITHDRAW)

Or via factory:

interface AccountEventFactory {
    @Characteristic(key = Operation::class, valueHandler = OperationHandler::class)
    fun accountMoneyChangeEvent(amount: Int): AccountMoneyChangeEvent
}

object Operation : CharacteristicKey {
    val WITHDRAW = OperationWithdraw
}

object OperationHandler : FactoryCharacteristicValueHandler {
    override fun handleFactory(event: Event, factory: FactoryConfiguration): CharacteristicValue {
        val operationCharacteristic = ...
        return operationCharacteristic
    }
}

Motivation

This would allow custom dispatches for characteristic specific listeners, which could be channel based and characteristic based instead of channel based only.

The main difference between Characteristics and Extension Additional Properties is that Characteristics are dynamic and does not require custom factory and custom class definitions, they could be set on the fly. And are easier to define.

Characteristic idea is to be something not bound to a specific group of events, but to an open group of events that may not correlate between them.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions