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