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

```
If you want to share a value between components, you should do a [Service](https://angular.io/tutorial/toh-pt4) that will be injected in each component where you need it.

```
@Injectable({
 providedIn: 'root',
})
export class ResultListService {
  public myResultList: string;
}

```

*(With the `providedIn: 'root'`, it will be injected at the root of your app so it will be instancied only one time and the same instance will be shared among components)*

Then you pass it in the constructor parameters of your componenents:

```
export class SidebarComponent   {

  constructor(public resultListService: ResultListService){}

  // this.resultListService.myResultList
}

```