When the user selects an item on the screen an action is triggered that requests data from the api and loads that data into the store for the selected item.
A selector is used to grab specific pieces of that returned data to create a graph.
The selector is returning undefined because the store doesn't have that data yet.
I either need the store/action/dispatch to signal to the call to the selector that it's ready OR allow the selector to keep requesting until it has the data it's looking for:
this.setItemDispatch(this.datetime, this.selectedItem, this.direction);
this.store.select(selectFlyoutTimelineBar(this.selectedItem, this.direction, 'Graph Title')).subscribe(x => {
console.log('data returned:', x);
});
The dispatch:
this.store.dispatch(
new LoadStationArriveTimelineDataAction({
station: selectedItem,
start: { startDate: currentDate },
query: this.codes,
lineQuery: this.lineCode
})
);