How to use didi - 4 common examples

To help you get started, we’ve selected a few didi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / table-js / src / Table.js View on Github external
(m.__depends__ || []).forEach(visit);

    if (hasModule(m)) {
      return;
    }

    addModule(m);

    (m.__init__ || []).forEach(function(c) {
      components.push(c);
    });
  }

  bootstrapModules.forEach(visit);

  var injector = new Injector(modules);

  components.forEach(function(c) {

    try {
      // eagerly resolve component (fn or string)
      injector[typeof c === 'string' ? 'get' : 'invoke'](c);
    } catch (e) {
      console.error('Failed to instantiate component');
      console.error(e.stack);

      throw e;
    }
  });

  return injector;
}
github bpmn-io / dmn-js / packages / dmn-js-shared / src / base / viewer / Viewer.js View on Github external
(m.__depends__ || []).forEach(visit);

    if (hasModule(m)) {
      return;
    }

    addModule(m);

    (m.__init__ || []).forEach(function(c) {
      components.push(c);
    });
  }

  bootstrapModules.forEach(visit);

  var injector = new Injector(modules);

  components.forEach(function(c) {

    try {

      // eagerly resolve component (fn or string)
      injector[typeof c === 'string' ? 'get' : 'invoke'](c);
    } catch (e) {
      console.error('Failed to instantiate component');
      console.error(e.stack);

      throw e;
    }
  });

  return injector;
github bpmn-io / diagram-js / lib / Diagram.js View on Github external
(m.__depends__ || []).forEach(visit);

    if (hasModule(m)) {
      return;
    }

    addModule(m);

    (m.__init__ || []).forEach(function(c) {
      components.push(c);
    });
  }

  bootstrapModules.forEach(visit);

  var injector = new Injector(modules);

  components.forEach(function(c) {

    try {

      // eagerly resolve component (fn or string)
      injector[typeof c === 'string' ? 'get' : 'invoke'](c);
    } catch (e) {
      console.error('Failed to instantiate component');
      console.error(e.stack);

      throw e;
    }
  });

  return injector;
github bpmn-io / diagram-js / lib / di.js View on Github external
var di = require('didi');

var Module = di.Module,
    Injector = di.Injector;

/**
 * Bootstrap an injector from a list of modules, instantiating a number of default components
 *
 * @param {Array} modules
 * @param {Array} components
 * @param {Object} config
 *
 * @return {didi.Injector} a injector to use to access the components
 */
function bootstrap(modules, components, config) {

  var configModule = {
    'config': ['value', config]
  };

didi

Dependency Injection for JavaScript

MIT
Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis

Popular didi functions