Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Characteristics #10

Open
JonathanxD opened this issue Dec 15, 2019 · 0 comments
Open

Event Characteristics #10

JonathanxD opened this issue Dec 15, 2019 · 0 comments
Assignees
Labels
Milestone

Comments

@JonathanxD
Copy link
Contributor

JonathanxD commented Dec 15, 2019

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.

@JonathanxD JonathanxD added this to the 1.9 milestone Dec 15, 2019
@JonathanxD JonathanxD self-assigned this Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant