Skip to content

Commit

Permalink
docu: send events from backend to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rind committed Sep 20, 2023
1 parent 2a0eb13 commit 5543756
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions dev-logbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ The frontend `LensView` simply calls:
```
No change in class `LensModel`.


### 5b get events from backend to frontend

Jupyter Widgets use Backbone.js but process messages.

You can debug messages received with `all`:

```javascript
view.on('all', () => console.log('hello view'));
view.model.on('all', (arg) => console.log(arg));
```

To pass a app specific message use the method `custom`:

```python
self.send({'method': 'custom', 'todo': 'highlight', 'idx': idx,})
```

```javascript
view.model.on('msg:custom', (payload) => console.log(payload));
```

## Step 6: get mouse events out of LensWidget via event listener

If additional data transformation is needed on the backend side, we can adapt 3 functions from
Expand Down
2 changes: 1 addition & 1 deletion src/scatterPlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ScatterPlot {
.classed('substrate', true)
.attr('transform', 'translate(' + MARGIN.left + ',' + MARGIN.top + ')');

// set the scales
// get some temporary scales just for showing axes
const x = prepareScale([], [0, 100]);
const y = prepareScale([], [100, 0]);

Expand Down

0 comments on commit 5543756

Please sign in to comment.