New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stencil-injection

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stencil-injection

Stencil-injection is small package to make dependencies injection in StencilJS

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Description 📄

Stencil-injection is small package to make dependencies injection in StencilJS. When a class is injected, only one instace of them are created.

Install 📦️

npm i --save stencil-injection

How to use ✏️

In the shared/services directory, create a file with the following code :

// class-to-injected.ts
export class ClassToInject {

  somePublicMethod() {
    // Do something.
  }
}
// some-other-class.ts
import { Inject } from 'stencil-injection';
import { ClassToInjected } from './class-to-inject';

export class SomeOtherClass {

  @Inject(ClassToInject) private injectedClass: ClassToInject;

  callInjectedClass() {
    this.injectedClass.somePublicMethod();
  }
}

Also it can be used in component:

import { Component, h, State } from '@stencil/core';
import { Inject } from 'stencil-injection';
import { ClassToInject } from 'shared/services/class-to-inject';
import { SomeOtherClass } from 'shared/services/some-other-class';

@Component({
  tag: 'some-component'
})
export class SomeComponent {

  @Inject(ClassToInject) private injectedClass: ClassToInject;
  @Inject(SomeOtherClass) private someOtherClass: SomeOtherClass;

  render() {
    // Render a beautiful component
  }
}

Keywords

FAQs

Package last updated on 02 May 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc