How to use the tsyringe.singleton function in tsyringe

To help you get started, we’ve selected a few tsyringe 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 Arianee / arianeeJS / src / core / wallet / services / arianeeEventEmitterService / ArianeeEventEmitter.ts View on Github external
newListener='newListener'
}
export class CustomEventEmitter extends EventEmitter {
  on (...args) {
    if (args[0] !== ArianeListenerEvent.newListener) {
      super.emit(ArianeListenerEvent.newListener, args[0]);
    }

    // @ts-ignore
    return super.on(...args);
  }

  addListener=this.on;
}

@singleton()
export class ArianeeEventEmitter {
  public EE = new CustomEventEmitter();
}
github Arianee / arianeeJS / src / core / wallet / services / globalConfigurationService / globalConfigurationService.ts View on Github external
import { injectable, singleton } from 'tsyringe';
import { ConsolidatedCertificateRequest } from '../../certificateSummary/certificateSummary';

@singleton()
export class GlobalConfigurationService {
    public defaultQuery: ConsolidatedCertificateRequest = {
      isRequestable: true,
      content: true,
      issuer: {
        waitingIdentity: false,
        forceRefresh: false
      },
      owner: true,
      events: true,
      arianeeEvents: true,
      advanced: true,
      messageSenders: true
    }

    getMergedQuery (query:ConsolidatedCertificateRequest = {}):ConsolidatedCertificateRequest {
github Arianee / arianeeJS / src / core / wallet / services / utilService / utilsService.ts View on Github external
import {Cert} from "@0xcert/cert";
import {singleton} from "tsyringe";
import {ConfigurationService} from "../configurationService/configurationService";
import {Web3Service} from "../web3Service/web3Service";

@singleton()
export class UtilsService {
  constructor(private web3Service: Web3Service, private configurationService: ConfigurationService) {
  }

  private get web3() {
    return this.web3Service.web3;
  }

  public signProofForRequestToken(
    certificateId: number,
    publicKeyNextOwner: string,
    privateKeyPreviousOwner: string
  ) {
    const data = this.web3.utils.keccak256(
      this.web3.eth.abi.encodeParameters(
        ["uint", "address"],
github Arianee / arianeeJS / src / core / wallet / services / configurationService / configurationService.ts View on Github external
import { singleton } from 'tsyringe';
import configurations from '../../../../configurations/appConfigurations';
import { ArianeeConfig } from '../../../../models/arianeeConfiguration';
import { ArianeeWalletBuilder } from '../../walletBuilder';

@singleton()
export class ConfigurationService {
  public arianeeConfiguration: ArianeeConfig;

  public walletFactory (): ArianeeWalletBuilder {
    return new ArianeeWalletBuilder(this.arianeeConfiguration);
  }

  public supportedConfigurations=configurations;
}
github Arianee / arianeeJS / src / core / libs / arianeeHttpClient / arianeeHttpClient.ts View on Github external
import axios from 'axios';
import { singleton } from 'tsyringe';

@singleton()
export class ArianeeHttpClient {
    private fetchingCache = {};

    /**
     * Calculate hash key from url and headers of a request
     * @param url
     * @param config
     * @return {string}
     */
    private static createKeyFromURL = (url, config) => {
      const hash = function (s) {
        let a = 1;
        let c = 0;
        let h;
        let o;
        if (s) {

tsyringe

Lightweight dependency injection container for JavaScript/TypeScript

MIT
Latest version published 11 months ago

Package Health Score

78 / 100
Full package analysis