this.timeline$ = app.selectedSites$.pipe(
debounceTime(2000),
switchMap(sites => this.interval.pipe(map(() => sites))),
switchMap(sites =>
analytics.timeline(sites, 60 * 24 * 2, 60).pipe(
map(result => {
const colors = getColors(result);
return {
labels: result[0].datapoints.map(pair => pair[1]),
datasets: (<any[]>result).map((target, i) => ({
pointRadius: 0,
label: target.target,
fill: false,
backgroundColor: colors[i % colors.length],
borderColor: colors[i % colors.length],
data: target.datapoints.map(pair => ({
y: pair[0],
x: pair[1]
}))
}))
};
})
)
),
share()
);
How can I modify this.timeline$ to emit null
when a new selectedSite is chosen (after debouncing), while loading the first set of data, and then automatically refresh every 30 seconds without emitting null before each refresh? I'm struggling to determine where to include the startWith(null) in this code snippet...