How I see it:

ParentComponent parent and many ChildComponent interact with IsAnyChildСheckedService

ParentComponent subscribed to an array of streams and listens to whether any ChildComponent status has changed to true, if at least one is true, but ParentComponent receives a true notification


I tried to just create an EventEmitter instance in the parent and pass it to each child element, but if the child elements run the message at the same time, the order is broken (discussion, code and possible hack here)

    1 answer 1

    Can be implemented via Observable
    IsAnyChildCheckedService :

     setArr(arr) { this.arr = arr; } getState(arr) { var self = this; return new Observable(observer => { setInterval(() => { if(self.isChangeArr(arr)) { //Проверка массива observer.next(true); } }, 5000); }); } 

    ParentComponent :

     ... listener() { this.isAnyChildСheckedService.subscibe(res => { // res = true }) } 

    and in ChildComponent through the service IsAnyChildCheckedService to transfer an array