// Create a thing that can be watched
// Convention to end observables with $
const chartSelection$ = new Subject();
// Inside your handler, stream can be injected
handleBrushMove(event) {
const { start, end } = event.selection;
chartSelection$.next({ start, end })
}
// Meanwhile, in another file...
chartSelection$.subscribe(selection => {
const { start, end } = selection;
minimap.moveTo(start, end);
})
// Add more subscriptions freely!
// Introduce throttle, debounce, merge (hotkeys) in a file
// decoupled from the rest of your charting logic...