DracoBlue / jsb

A very extendable Toolkit to inject Javascript Behaviour into rendered HTML without Inline Javascript. (jsb was formerly known as JsBehaviourToolkit)
http://dracoblue.net
Other
52 stars 8 forks source link

racecondition in jsb whenFired #24

Closed DracoBlue closed 9 years ago

DracoBlue commented 9 years ago

/cc by @axten

        /*
         * Fire the event, it should be catched with the next whenFired
         */
        jsb.fireEvent('WHEN_FIRED_RACE_CONDITION_TEST', {
            "id": 1
        });

        jsb.whenFired('WHEN_FIRED_RACE_CONDITION_TEST', {"id": 1}, function(values)
        {
            /* This happend up to jsb 2.0.0, to be values.id == 2, because the next event is already the last event */
            if (values.id == 1) {
                that.markAsSucceeded();
            } else {
                that.markAsFailed();
            }
        });

        jsb.fireEvent('WHEN_FIRED_RACE_CONDITION_TEST', {
            "id": 2
        });

fails.