saraedum / ipyvue-time-series

Real-Time Plots in Jupyter
2 stars 0 forks source link

Turn comm interface into a separate package #21

Closed saraedum closed 1 year ago

saraedum commented 3 years ago

So we can use it to solve https://github.com/flatsurf/ipyvue-flatsurf/issues/35.

Currently, CommWidget provides basic communication in both directions:

There are some problems with this approach:

The interface we would like to see (on the Python side.):

class Client:
  def send(self, data): ...
  async def query(self, data): ...

And the same on the JavaScript side.

A Basic Use Case

Let's suppose that we want to query the client for a half edge, i.e., the user should click on one and that is returned to the server.

We cannot send that query to all clients as is, since we would have to cancel all these queries once a click happened in one frontend. So instead, we need to perform this query with a cancellation token that is somehow hidden away on the client. Then the server can invoke this cancellation token once any of the clients responds. This means that CommWidget can implement send as for client in clients: send but needs to implement query differently to supporte:

requests = self.query(...)
await any of requests
for request in requests: request.cancel()
saraedum commented 3 years ago

This is now https://github.com/flatsurf/ipyvue-async.

saraedum commented 1 year ago

We are not using that package yet here. However, that package is now part of ipyμvue. See #36.