コード例 #1
0
def test_many_events_with_dictionary():
    subject = Observable()
    subject.on({  # setting events of an observable with dictionary
        'one': one_handler,
        'two': two_handler,
        'custom': CustomEvent(),
        'many': [one_handler, two_handler]})
    subject.trigger('one two custom many', 1, 2, a=3, b=4)
コード例 #2
0
def test_event_with_handler_attached():
    subject = Observable()
    subject.on('one', one_handler)
    subject.on('two', two_handler)
    assert(subject.events['one'] is subject.one)
    assert(subject.events['two'] is subject.two)
    # trigger
    subject.one(1, 2, a=3, b=4)
    subject.one.trigger(1, 2, a=3, b=4)
    subject.trigger('one', 1, 2, a=3, b=4)
    subject.events['one'].trigger(1, 2, a=3, b=4)
    subject.trigger('one two', 1, 2, a=3, b=4)
    subject.trigger(['one', 'two'], 1, 2, a=3, b=4)