Socket
Book a DemoInstallSign in
Socket

ember-container

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-container

ember owner as destructable object

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Containers for Ember

The dependency injection in ember works through the Owner. An object on which objects can be registered and later on looked up. It doesn't have the most convenient API when passing around the owner as "container" for dependencies. Here comes ember-container into play. A wrapper around owner for a nicer API to embers DI.

Example

Let's say we want to access isAuthenticated from session service from ember-simple-auth in a function.

function canLogin({ services }) {
  const { session } = services;

  return session.isAuthenticated;
}

which we invoke from a component:

import { getOwner } from '@ember/application';
import Component from '@glimmer/component';
import makeContainer from 'ember-container';

export default class MyComponent extends Component {

  get canLogin() {
    return canLogin(makeContainer(getOwner(this)));
  }
}

Whilst this is more of a showcase to demo its usage; at best, this is used as a low-level API as part of your libraries that pipe through the Owner into userland code.

Installation

tbd.

Keywords

ember-addon

FAQs

Package last updated on 14 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.