"use strict";

var
Promise = require('./promise');


module.exports = function (API) {
  var
  self = Object.create(null),
  promise = Promise.resolve(API);

  self.init = function (initializer) {
    promise = promise.then(function () {
      return initializer(API);
    });
    return self;
  };

  return self;
};

"use strict";

var
Promise = require('./promise');


module.exports = function (API) {
  var
  self         = Object.create(null),
  initializers = [],
  promise      = Promise.resolve(API);

  self.init = function (initializer) {
    initializers.push(initializer);
    promise = promise.then(function () {
      initializer(API);
      return initializer.stop().then(initializer.start);
    });
    return self;
  };

  self.stop = function () {
    return Promise.all(initializers.map(function (initializer) {
      if (initializer && initializer.stop) {
        return initializer.stop();
      } else {
        return Promise.resolve(true);
      }
    }));
  };

  return self;
};

Add stop() method to Initializer.
Add stop() method to Initializer.

	modified:   lib/initializer.js
