Commit 492f33b6 authored by Sumit Sahrawat's avatar Sumit Sahrawat

Small changes to MsgSpec.md

- Formatting issues: Bad numbering.
- Clarify usage of custom messages.
parent e1dafd07
...@@ -54,6 +54,8 @@ message to the frontend on the widget's comm. ...@@ -54,6 +54,8 @@ message to the frontend on the widget's comm.
} }
``` ```
## Custom messages
* Widgets can also send a custom message, having the form: * Widgets can also send a custom message, having the form:
```json ```json
...@@ -63,6 +65,9 @@ message to the frontend on the widget's comm. ...@@ -63,6 +65,9 @@ message to the frontend on the widget's comm.
} }
``` ```
This message is used by widgets for ad-hoc syncronization, event handling and other stuff. An example
is mentioned in the next section.
## Handling changes to widget in the frontend ## Handling changes to widget in the frontend
Changes to widgets in the frontend lead to messages being sent to the backend. These messages have Changes to widgets in the frontend lead to messages being sent to the backend. These messages have
...@@ -70,28 +75,28 @@ two possible formats: ...@@ -70,28 +75,28 @@ two possible formats:
1. Backbone.js initiated sync: 1. Backbone.js initiated sync:
```json ```json
{ {
"method": "backbone", "method": "backbone",
"sync_data": { "<changes to sync with the backend>" } "sync_data": { "<changes to sync with the backend>" }
} }
``` ```
These messages are sent by the Backbone.js library when some change is made to a widget. For These messages are sent by the Backbone.js library when some change is made to a widget. For
example, whenever a change is made to the text inside a `TextWidget`, the complete contents are sent example, whenever a change is made to the text inside a `TextWidget`, the complete contents are sent
to the kernel so that the kernel stays up-to-date about the widget's contents. to the kernel so that the kernel stays up-to-date about the widget's contents.
2. Custom message: 2. Custom message:
```json ```json
{ {
"method": "custom", "method": "custom",
"content": { "<custom message data>" } "content": { "<custom message data>" }
} }
``` ```
This form is generally used to notify the kernel about events. For example, the `TextWidget` sends a This form is generally used to notify the kernel about events. For example, the `TextWidget` sends a
custom message when the text is submitted by hitting the 'Enter' key. custom message when the text is submitted by hitting the 'Enter' key.
--- ---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment