How to use the injection-js.Optional function in injection-js

To help you get started, we’ve selected a few injection-js 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 Hotell / blogposts / 2018-06 / ts-react-di / src / app / core / logger.service.ts View on Github external
constructor(
    @Optional()
    @Inject(LoggerConfig)
    protected config: Config
  ) {
    if (!config) {
      this.config = defaultConfig
    }
  }
  protected logs: string[] = [] // capture logs for testing
github Hotell / rea-di / examples / counter-with-multiple-injectors / src / app / multiply-counter.service.ts View on Github external
constructor(
    @Optional()
    @Inject(MultiplyCounterConfig)
    private config: MultiplyCounterConfig,
    public logger: Logger
  ) {
    super(logger)
    this.config = config || defaultConfig
  }
  onIncrement() {