Question: Although I've been using python for a while, and a common pattern you see is these two statements:

```
def main():
    # Fancy code here 
if __name__ == "__main__":
    main()

```

My question is, why wouldn't you use this pattern instead?

```
if __name__ == "__main__":
    # Fancy code here

```

Is this just in case you want to import main from another place? Or is there some other reason you might want to do this?

Answer: 
I'd recommend using a `Service` with a `BehaviorSubject` exposed `asObservable` and `subscribe`ing to it in all the components where you want to get the updated `resultList`

So you'll have a service:

```
import { BehaviorSubject, Observable } from 'rxjs';
...
export class ResultListService {
  private resultList: BehaviorSubject<any[]> = new BehaviorSubject<any[]>(null);
  public resultList$: Observable<any[]> = this.resultList.asObservable();

  updateResultList(updatedList) {
    this.resultList.next(updatedList);
  }
}

```

In the dialog component, you'll use the `updateResultList` method and pass it the updatedResultList:

```
constructor(..., private resultListService: ResultListService) {}
...
this.resultListService.updateResultList(updatedResultList);

```

Now in any component where you want the updated `resultList`, just `subscribe` to `resultList$` from `ResultListService`:

```
constructor(..., private resultListService: ResultListService) {}
...
this.resultListService.resultList$
  .subscribe(resultList => console.log('This is the updated resultList: ', resultList));

```
There are other options besides chaining @Input and @Output parameters through multiple components or using a service (which is likely the best solution if you are new to Angular), one of which is making use of shared state.

Using a state management framework such [ngrx](https://www.npmjs.com/package/@ngrx/store), [ngxs](https://www.npmjs.com/package/@ngxs/store) or [akita](https://www.npmjs.com/package/@datorama/akita) allows you to share both state and changes to that state between components - in this case arrays and changes to their content.

Once set up the store would manage adding the items selected in your child component to the array referenced in the parent component. The two components would not even have to be related to each other.

These two tutorials for [ngrx](https://youtu.be/9P5DTlg9oLc) and [ngxs](https://youtu.be/SfiO3bDUK7Q) both cover a use case similar to yours. The fact that you are using a modal dialog and two lists does not change anything in regards to how the store is used.

This is likely out of scope for what you are trying to accomplish but something you could keep in mind.