Skip to content

Add feature: onBrushListener #164

Open
@josesaranda

Description

@josesaranda

Normally if you're going to use a third party library in your project you'll want to capture the library events.
In this case i think is useful to get onBrush event in order to use that information in the client.

This could be something like this:

class App {

...
private onBrush? : (name : string, value : number[]) => void; 

constructor(...){...}

addOnBrushListener = (onBrush : (name : string, value : number[]) => void) => {
  this.onBrush = onBrush;
}
...
private async initializeView(name: V, view: View<D>) {
  ...
  vegaView.addSignalListener("brush", async (_name, value) => {
       ...
        if (this.onBrush) {
          this.onBrush(view.dimension.name, value);
        }
       ...
  });
  ...
}
...
}

And how to use?

let app = new App(views, db, {
  config: {
    ...
  },
  logger: logger,
  cb: _app => {
    document.getElementById("loading")!.style.display = "none";
  }
});

app.addOnBrushListener((name : string, value : number[]) => {
  console.log('on brush', name, value); // i.e will print : on brush ARR_TIME [10.48, 12.88]
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions