ed4becky
ed4becky

Reputation: 1630

RSJX Observable not returning data

The following code, when subscribed to, returns an expected array of objects.

this.store.select (this.selectors.evidenceSelector);

The objects include a 'subjectId' field. This code, based on multiple examples on the web, returns nothing when subscribed to:

this.store
      .select (this.selectors.evidenceSelector)
      .pipe (
        groupBy (ev => ev['subjectId']),
        mergeMap (group$ => group$.pipe(toArray())),
      );

The subscription never gets triggered...

Any suggestions?

Upvotes: 0

Views: 51

Answers (1)

maxime1992
maxime1992

Reputation: 23813

Oh after reading again... I think I've figured out what's going on here.

toArray will only emit a value when the stream is closed. As you're listening from your store (which will never be closed), you'll never get anything under the toArray. You have to use something like scan if you want to accumulate and show a result on every new emission.

Upvotes: 2

Related Questions