Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tm.event.EventDispatcher.prototype.one #97

Open
daishihmr opened this issue Feb 25, 2014 · 0 comments
Open

tm.event.EventDispatcher.prototype.one #97

daishihmr opened this issue Feb 25, 2014 · 0 comments

Comments

@daishihmr
Copy link
Contributor

oneメソッドが正常に動作しないようです。

tm.main(function() {
    var count = 0;

    var test = tm.event.EventDispatcher();
    test.one("testevent", function() { count += 1; console.log("testevent 1") });
    test.one("testevent", function() { count += 1; console.log("testevent 2") });
    test.one("testevent", function() { count += 1; console.log("testevent 3") });
    test.one("testevent", function() { count += 1; console.log("testevent 4") });
    test.one("testevent", function() { count += 1; console.log("testevent 5") });

    test.fire(new tm.event.Event("testevent"));

    console.assert(count === 5);

    test.firenew tm.event.Event("testevent"));

    console.assert(count === 5);
});

上記コードを実行すると、以下の様な出力となります。

testevent 1 index.html:13
testevent 3 index.html:15
testevent 5 index.html:17
Uncaught TypeError: Cannot call method 'call' of undefined tmlib.js:1930

イベントハンドラ内でイベントリスナーを削除しているのが原因と思われます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant