Global project counter with behavior subject

Hello,
I´m trying to share my count results to two other components after filtering projects. When I filter my projects I want to share the count to two other components. And when I repeat the filter I want update the count for the other components.

I think the most important file is the service:

export class ProjectService {
    api = '/project';

    private countProject = new BehaviorSubject(0);

    constructor(private http: HttpClient) {}

   getCount(term?, queryString?): Observable<Filter> {
        return this.http.post<Filter>(`${this.api}/count.json`, {
            qf: queryString,
            q: [{
                what: {id: 13},
                search: {value: term}
            }]
        });
    }

    getCountObservable(): Observable<number> {
        return this.countProject.asObservable();
    }

And my typescript in one of my components (FilterComponent):

  countProject = 0;

  constructor(  ) {
    this.projectService.getCountObservable().subscribe(res => {
      this.countProject = res;
    });
  }

Any idea how I can update the countProject property for the other components, in that case only FilterComponent?

Thanks for any tip!

Mhh i don’t know if i get your Question correctly. You want to observe a new Value to the countProject Subject?

Yes, I want update the countProject. I think in the service getCount I need a subscribe to get the countProject, but I don´t know how.

When I get back the parameter term from the ngModel of my searchbar, I want to update the countProject and share the new countProject to other components.

Do you know what I meen?

on a Subject you can call next() to emit any Value that every Component that is subscribed to this subject will receive

Ok thanks for your help!

I´ll try a solution with next()