A simple mutex implementation using Ember (RSVP) Promises. This is pretty much a copy of https://github.com/plenluno/promise-mutex adjusted for Ember.
ember install ember-mutex
import Mutex from 'ember-mutex';
let mutex = Mutex.create();
let sayHelloSynced = function() {
mutex.lock(function() {
return new Ember.RSVP.Promise(function(resolve) {
console.log('hello');
Ember.run.later(null, resolve, 1000);
});
});
};
sayHelloSynced(); // should print 'hello' immediately
sayHelloSynced(); // will print 'hello' after 1000ms
ember try:testall