Skip to content

Commit

Permalink
WIP update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Jun 12, 2018
1 parent 6b88d89 commit e905dd8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/services/src/kernel/comm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
* Get the callback for a comm close event.
*
* #### Notes
* This is called when the comm is closed from either the server or
* client.
* This is called when the comm is closed from either the server or client.
*
* **See also:** [[ICommClose]], [[close]]
*/
Expand All @@ -64,8 +63,10 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
* Set the callback for a comm close event.
*
* #### Notes
* This is called when the comm is closed from either the server or
* client.
* This is called when the comm is closed from either the server or client. If
* the function returns a promise, and the kernel was closed from the server,
* kernel message processing will pause until the returned promise is
* fulfilled.
*
* **See also:** [[close]]
*/
Expand All @@ -82,6 +83,10 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {

/**
* Set the callback for a comm message received event.
*
* #### Notes
* This is called when a comm message is received. If the function returns a
* promise, kernel message processing will pause until it is fulfilled.
*/
set onMsg(cb: (msg: KernelMessage.ICommMsgMsg) => Promise<void> | void) {
this._onMsg = cb;
Expand Down Expand Up @@ -171,6 +176,7 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
let onClose = this._onClose;
if (onClose) {
let ioMsg = KernelMessage.createMessage(options, content, metadata, buffers);
// TODO: should we somehow pause message processing if onClose returns a promise?
onClose(ioMsg as KernelMessage.ICommCloseMsg);
}
this.dispose();
Expand Down

0 comments on commit e905dd8

Please sign in to comment.