Komtet / mediator

A library implements the Mediator pattern to make your code extensible
MIT License
19 stars 3 forks source link

Automatic event name detection #1

Closed ghost closed 8 years ago

ghost commented 8 years ago

Based on class name for example:

class EventType(type):
    def __call__(cls, *args, **kwargs):
        event = type.__call__(cls, *args, **kwargs)
        event.set_name(str(cls))
        return event

    def __str__(cls):
        return cls.__name__

class BaseEvent(Event, metaclass=EventType):
    pass