0.0.0 • Published 7 years ago

ember-mutex v0.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Ember-mutex

Build Status Code Climate Test Coverage Issue Count

A simple mutex implementation using Ember (RSVP) Promises. This is pretty much a copy of https://github.com/plenluno/promise-mutex adjusted for Ember.

Installation

ember install ember-mutex

Usage

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

Running Tests

ember try:testall