Prodigious-Aim-Solutions/Kronicle6

View on GitHub
build/Core.js

Summary

Maintainability
C
1 day
Test Coverage
"use strict";

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

require("babel/polyfill");
var PubSub = _interopRequire(require("pubsub-js"));

var events = require("./EventTypes.js").events;


// # Main Kronicle.Core class
// depends: pubsub-js, [Kronicle.EventTypes](EventTypes.html)
// This is the main Kronicle Core. This class is used to load all modules that are to be used in the Kronicle app.
// Events are fired at various points to indiciate the status and can be used as hooks for library modules.
// Constructor an array of Kronicle modules as an argument.
var Core = exports.Core = function Core(modules) {
    _classCallCheck(this, Core);

    PubSub.publish(events.Initialized);

    this.addedModules = {};

    PubSub.publish(events.BeforeModulesLoad, modules);

    for (var _iterator = modules[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
        var mod = _step.value;


        this.addedModules[mod.name] = mod;
        PubSub.publish(events.ModuleLoaded, mod);
    }

    PubSub.publish(events.AfterModulesLoad, modules);
    PubSub.publish(events.Ready);
};

Object.defineProperty(exports, "__esModule", {
    value: true
});