patryk-developer
6/6/2018 - 9:15 AM

Wzorzec wstrzykiwania zależności

class DataSource {
  data
  
  constructor(private config) {
  this.data = 'data from' + config.sourceUrl
  
  }
}

class ComponentA {
  constructor() {
    const dataSource = new DataSource({
      sourceUrl: 'http://some.real.server/'
    )}
    console.log('>>>Getting' + dataSource)
  }
}

const cmp = new CompomentA()