Show More
@@ -106,7 +106,7 b' class Widget(LoggingConfigurable):' | |||||
106 |
|
106 | |||
107 | # Event handlers |
|
107 | # Event handlers | |
108 | def _handle_msg(self, msg): |
|
108 | def _handle_msg(self, msg): | |
109 |
"""Called when a msg is rec |
|
109 | """Called when a msg is received from the frontend""" | |
110 | data = msg['content']['data'] |
|
110 | data = msg['content']['data'] | |
111 | method = data['method'] |
|
111 | method = data['method'] | |
112 |
|
112 | |||
@@ -115,7 +115,7 b' class Widget(LoggingConfigurable):' | |||||
115 | # Handle backbone sync methods CREATE, PATCH, and UPDATE all in one. |
|
115 | # Handle backbone sync methods CREATE, PATCH, and UPDATE all in one. | |
116 | if method == 'backbone' and 'sync_data' in data: |
|
116 | if method == 'backbone' and 'sync_data' in data: | |
117 | sync_data = data['sync_data'] |
|
117 | sync_data = data['sync_data'] | |
118 |
self._handle_rec |
|
118 | self._handle_receive_state(sync_data) # handles all methods | |
119 |
|
119 | |||
120 | # Handle a custom msg from the front-end |
|
120 | # Handle a custom msg from the front-end | |
121 | elif method == 'custom': |
|
121 | elif method == 'custom': | |
@@ -123,8 +123,8 b' class Widget(LoggingConfigurable):' | |||||
123 | self._handle_custom_msg(data['custom_content']) |
|
123 | self._handle_custom_msg(data['custom_content']) | |
124 |
|
124 | |||
125 |
|
125 | |||
126 |
def _handle_rec |
|
126 | def _handle_receive_state(self, sync_data): | |
127 |
"""Called when a state is rec |
|
127 | """Called when a state is received from the frontend.""" | |
128 | for name in self.keys: |
|
128 | for name in self.keys: | |
129 | if name in sync_data: |
|
129 | if name in sync_data: | |
130 | value = self._unpack_widgets(sync_data[name]) |
|
130 | value = self._unpack_widgets(sync_data[name]) | |
@@ -133,7 +133,7 b' class Widget(LoggingConfigurable):' | |||||
133 |
|
133 | |||
134 |
|
134 | |||
135 | def _handle_custom_msg(self, content): |
|
135 | def _handle_custom_msg(self, content): | |
136 |
"""Called when a custom msg is rec |
|
136 | """Called when a custom msg is received.""" | |
137 | for handler in self._msg_callbacks: |
|
137 | for handler in self._msg_callbacks: | |
138 | if callable(handler): |
|
138 | if callable(handler): | |
139 | argspec = inspect.getargspec(handler) |
|
139 | argspec = inspect.getargspec(handler) | |
@@ -271,7 +271,7 b' class Widget(LoggingConfigurable):' | |||||
271 |
|
271 | |||
272 |
|
272 | |||
273 | def on_msg(self, callback, remove=False): # TODO: Use lambdas and inspect here |
|
273 | def on_msg(self, callback, remove=False): # TODO: Use lambdas and inspect here | |
274 |
"""Register or unregister a callback for when a custom msg is rec |
|
274 | """Register or unregister a callback for when a custom msg is received | |
275 | from the front-end. |
|
275 | from the front-end. | |
276 |
|
276 | |||
277 | Parameters |
|
277 | Parameters |
General Comments 0
You need to be logged in to leave comments.
Login now