Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: onBrushListener #164

Open
josesaranda opened this issue Oct 2, 2019 · 1 comment
Open

Add feature: onBrushListener #164

josesaranda opened this issue Oct 2, 2019 · 1 comment

Comments

@josesaranda
Copy link

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]
});
@domoritz
Copy link
Member

domoritz commented Oct 2, 2019

Thanks. Maybe the cleaner approach would be to just give access to the Vega views. I wouldn't have to reinvent the wheel then since Vega already supports registering and de-registering listeners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants