Created
December 19, 2015 00:52
-
-
Save agoose77/7248548686e229a6a7c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hive | |
class EventBindClass: | |
def __init__(self): | |
pass | |
class EventCls: | |
def __init__(self): | |
self._add_handler = None | |
def set_add_handler(self, add_handler): | |
add_handler(self._on_event) | |
def set_register_bind_cls(self, register_bind_cls): | |
# Register some bind class required to redeclare "add_handler" | |
# Called from plugin/sockets, hence once per BindEvent instance | |
pass | |
def _on_event(self, event): | |
# Pass events to the bound hive if appropriate | |
pass | |
def declare_bind(meta_args): | |
meta_args.bind_event = hive.parameter("bool", True) | |
meta_args.event_dispatch_mode = hive.parameter("str", 'by_leader', {'by_leader', 'all'}) | |
def build_bind(cls, i, ex, args, meta_args): | |
i.event_dispatch_mode = hive.property(cls, "dispatch_mode", "str", meta_args.event_dispatch_mode) | |
if meta_args.bind_event: | |
ex.set_register_bind_cls = hive.socket(cls.set_register_bind_cls, identifier=("bind", "register_class")) | |
ex.set_add_handler = hive.socket(cls.set_add_handler, identifier=("event", "add_handler")) | |
BindEvent = hive.dyna_hive("BindEvent", build_bind, declarator=declare_bind, cls=EventCls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment