GHPython eventhandling for CustomDisplay

Hey, Im trying to make my CustomDisplays work out with preview toggling of the ghPython-component on the canvas. My approach is to intercept the ghenv.Component.ObjectChanged event and then do ghenv.Component.ExpireSolution(True). I have two issues however.

  1. My event handler class cant seem to run the assigned functions on fired events, should i use func(sender, e)-pattern for Grasshopper events or how can I deal with them in th ghPython node? The code below makes the node update on fired events if i change event_handler.subscribe(ghenv.Component.ObjectChanged,event_handler.test,'obj_changed') to event_handler.subscribe(ghenv.Component.ObjectChanged,ghenv.Component.ExpireSolution(True),'obj_changed'). Why is this? (sry about the broken formatting, I don’t get why it happend)

class event_handler():
def init(self):
if ‘events’ not in sc.sticky:
sc.sticky[‘events’] = {}
event_handler.subscribe(ghenv.Component.ObjectChanged,event_handler.test,‘obj_changed’)

@staticmethod
def test(sender, e):
    print sender, e
    ghenv.Component.ExpireSolution(True)

@staticmethod
def subscribe(event, func, key):
    if key not in sc.sticky['events']:
        sc.sticky['events'][key] = event
    if key not in sc.sticky:
        sc.sticky[key] = func
        event += sc.sticky[key]

@staticmethod
def unsubscribe_all():
    for key in sc.sticky['events']:
        if key in sc.sticky:
            sc.sticky['events'][key] -= sc.sticky[key]
            sc.sticky.Remove(key)
    sc.sticky['events'] = {}

my second issue is to limit the event only to Hidden toggle, and not zoom, pan etc. But I guess I can just typecheck or something?

Many thanks

Jakob