import { Injectable } from '@angular/core' ; import { Store } from '@ngrx/store' ; import { Web3Service } from './web3.service' ; import { KudosPollService } from './contracts/kudos-poll.service' ; @ Injectable ( ) export class KudosPollFactoryService { private kudosPollInstances : { [ address ] : KudosPollService ; } = { } ; constructor ( private web3Service , protected store ) { } getKudosPollServiceAt ( address ) { if ( + address === 0 ) { return ; } if ( this . kudosPollInstances [ address ] ) { return this . kudosPollInstances [ address ] ; } const kudosPollService = new KudosPollService ( this . web3Service , this . store ) ; kudosPollService . initAt ( address ) ; this . kudosPollInstances [ address ] = kudosPollService ; return kudosPollService ; } }