Skip to content

Commit 995d2f2

Browse files
fix(translator): specify the translator to apply for each callback
1 parent c7e66d4 commit 995d2f2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

trame_server/state.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,9 @@ def flush(self):
294294
self._pushed_state.update(self._pending_update)
295295
self._pending_update.clear()
296296

297-
reverse_translated_state = self.translator.reverse_translate_dict(
298-
self._pushed_state
299-
)
300-
301297
# Execute state listeners
302298
self._state_listeners.add_all(_keys)
303-
for fn in self._state_listeners:
299+
for fn, translator in self._state_listeners:
304300
if isinstance(fn, weakref.WeakMethod):
305301
callback = fn()
306302
if callback is None:
@@ -312,6 +308,7 @@ def flush(self):
312308
if not inspect.iscoroutinefunction(callback):
313309
callback = reload(callback)
314310

311+
reverse_translated_state = translator.reverse_translate_dict(self._pushed_state)
315312
coroutine = callback(**reverse_translated_state)
316313
if inspect.isawaitable(coroutine):
317314
asynchronous.create_task(coroutine)
@@ -366,7 +363,7 @@ def register_change_callback(func):
366363
if name not in self._change_callbacks:
367364
self._change_callbacks[name] = []
368365

369-
self._change_callbacks[name].append(func)
366+
self._change_callbacks[name].append((func, self._translator))
370367
return func
371368

372369
return register_change_callback

0 commit comments

Comments
 (0)