import { Injectable } from '@angular/core' ; import { Store } from '@ngrx/store' ; import { childrenEntities , relatedEntity , rootEntities , rootEntity } from 'ngrx-entity-relationship' ; import { relationships } from 'ngrx-entity-relationship/rxjs' ; import { FightCollection } from './collections/fight.collection' ; import { HeroCollection } from './collections/hero.collection' ; import { VillainCollection } from './collections/villain.collection' ; @ Injectable ( ) export class SelectorService { constructor ( protected readonly store , protected readonly fight , protected readonly hero , protected readonly villain ) { } public readonly fights$ = this . fight . selectors$ . entities$ . pipe ( relationships ( this . store , rootEntities ( rootEntity ( this . fight , relatedEntity ( this . hero , 'heroId' , 'hero' ) , relatedEntity ( this . villain , 'villainId' , 'villain' ) ) ) ) ) ; public readonly heroes$ = this . hero . selectors$ . entities$ . pipe ( relationships ( this . store , rootEntities ( rootEntity ( this . hero , childrenEntities ( this . fight , 'heroId' , 'fights' , relatedEntity ( this . villain , 'villainId' , 'villain' ) ) ) ) ) ) ; public readonly villains$ = this . villain . selectors$ . entities$ . pipe ( relationships ( this . store , rootEntities ( rootEntity ( this . villain , childrenEntities ( this . fight , 'villainId' , 'fights' , relatedEntity ( this . hero , 'heroId' , 'hero' ) ) ) ) ) ) ; }