K
K
Konstantin2020-12-27 14:35:33
Angular
Konstantin, 2020-12-27 14:35:33

Why is the rxjs stream not changing?

Available:

public events$: BehaviorSubject<IEvent[]> = new BehaviorSubject<IEvent[]>([]);


Data is requested and forwarded to events$ :

this.load().subscribe((response) => {
      this.events$.next(response);
    });


There is a function that changes the data in the stream:

public checkAll() {
    this.events$.pipe(
      map((events: IEvent[]) => {
        return events.map((event: IEvent) => {
          event.checked_export = !event.checked_export;
          return event;
        });
      })
    );
  }


Why, if you subscribe to events$ , nothing changes after calling the checkAll()

function As it seems to me, you need to do this.events$ = this.events$.pipe()...or forward the mapped object:this.events$.next(mapped)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question