How to use the inversify.Container.merge function in inversify

To help you get started, we’ve selected a few inversify 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 kristianmandrup / red-elements / packages / red-deploy / src / _container / index.ts View on Github external
// auto bind via conventions
Object.keys(widgets).map(widgetName => {
  const widgetTypeName = widgetName.toLowerCase()
  const type = WIDGET_TYPES[widgetTypeName]

  const clazz = widgets[widgetName]
  if (type && isClassy(clazz)) {
    widgetContainer.bind(type).to(clazz)
  }
})

// merge container with runtime container here?
// see /docs on Service injection
// Container.merge(a: Container, b: Container)

const container = Container.merge(widgetContainer, runtimeContainer)

// might be easier to use
const containers = {
  widget: widgetContainer,
  runtime: runtimeContainer
}

// export both the app container (simply named container) from merge
// and the widget only container named widgetContainer
export {
  lazyInject,
  WIDGET_TYPES,
  $TYPES,
  containers,
  container,
  widgetContainer