n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.19k stars 185 forks source link

Implement message `clear_output` #155

Closed zya closed 6 years ago

zya commented 6 years ago

Jupyter seems to have support for clearing the output: http://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output Kernels like iPython make it available through a function (clear_output) that one can call. So, I have two questions:

  1. Is there a feature in the current implementation to achieve this? If not, can this be added?
  2. Is there a way for a user to send custom jupyter message in ijavascript Something like this:
    const message = {
    headers: {
       msg_type: 'clear_output'
    }
    }
    $$.sendCustomMessage(message)
n-riesco commented 6 years ago

If what you need is just to clear a display. This should work:

// In[1]:
var $display = $$.display("test");
$display.text("Hello, World!");

// In[2]:
$display.text("");
n-riesco commented 6 years ago
  1. Is there a way for a user to send custom jupyter message in ijavascript?

The short answer is no, IJavascript doesn't provide an API for sending custom Jupyter messages.

If what you have in mind is extending the Jupyter messaging protocol, the protocol already defines a message for that purpose. See custom messages.

comm-* messages haven't been implemented in IJavascript yet. I will update issue #100, when I start working on it.