Skip to content

akatov/ember-mutex

Repository files navigation

Ember-mutex

Build Status Code Climate Test Coverage Issue Count npm Version Ember Observer Score

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published