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

events should be dispatched asynchronously #50

Open
millermedeiros opened this issue Feb 21, 2013 · 2 comments
Open

events should be dispatched asynchronously #50

millermedeiros opened this issue Feb 21, 2013 · 2 comments

Comments

@millermedeiros
Copy link
Owner

it was a poor design decision to dispatch the signals as soon as the user calls setHash, events should always be async to avoid headaches (avoid cases where user might not expect something to happen in between).

@millermedeiros
Copy link
Owner Author

#48 is also related to this.

@eugene-eeo
Copy link

Hi, I just wrote a library called stateless.js which is quite similar but simpler, and I stumbled upon your lib. Asynchronous dispatches can be done via having an event listener on the hashchange event. Those are fired asynchronously on most/all browsers- Firefox, Chrome, Safari (I don't know about IE).

However from my experience testing it is quite tedious; I don't know what kind of asynchronous constructs are offered by QUnit which is used as your test runner if I'm not mistaken. For example in Mocha:

describe(spec, function() {
  it(spec, function(done) {
    hasher.changed.add(function(){
      done();
    });
    hasher.setHash('foo');
  });
});

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

No branches or pull requests

2 participants