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));

```
Component A- HTML

```
<button (click) = "changeFoo()">Change Value</button>

```

Component A- Typpescript

```
    import { SharedService } from './../../shared.service';
constructor(private sharedService: SharedService) {}

```

Component B-Html

```
<div style="margin:0; padding:0">
            {{xIsANumberVal == null? '' : "Value Passed From A Component 
            Comp(Parent): "+xIsANumberVal }}
</div>

```

Component B- Typescript

```
import { SharedService } from './../../shared.service';
 xIsANumberVal!: number;
constructor(
    private sharedService: SharedService
  ) {}

ngOnInit() {
    this.receiveValueFromService();
  }

    receiveValueFromService() {
        this.sharedService.valueSource.subscribe(value => {
          this.xIsANumberVal = value;
        });
      }

```

Shared Service

```
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class SharedService {

  xIsANumberVal: number = 5;
  valueSource: Subject<number> = new Subject();

  get abc(): Subject<number> {
    return this.valueSource;
  }

  constructor() { }

  changeFoo(xIsANumberVal: number) {
    this.valueSource.next(xIsANumberVal);
  }
}

```

Working Example: <https://stackblitz.com/edit/github-u6xvad?file=src%2Fapp%2Fsecond%2Fsecond.component.ts>