🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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
Package was removed
Sorry, it seems this package was removed from the registry

stencil-injection

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

1.0.0
unpublished
latest
Source
npm
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

typescript

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