

def once(self, event, *handlers):
    'register a handler to a specified event, but remove it when it is triggered'

    def _once_wrapper(*handlers):
        'wrapper for once decorator'

        def _wrapper(*args, **kw):
            'call wrapper'
            list(map((lambda x: x(*args, **kw)), handlers))
            self.off(event, _wrapper)
        return _wrapper
    if handlers:
        return self.on(event, _once_wrapper(*handlers))
    return (lambda x: self.on(event, _once_wrapper(x)))

dataset/ETHPy150Open timofurrer/pyobservable/observable/core.py Observable.once/original