-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
We need to allow protection from race conditioning of hook attachments.
A similar work was done in ReactTagNode with the '__reactive_reset_content' function. (see
django-reactive-framework/src/django_reactive_framework/templatetags/reactive.py
Lines 307 to 330 in 4581e3b
| 'var __reactive_block_reset = true;\n' + \ | |
| 'var __reactive_need_reset = false;\n' + \ | |
| 'function __reactive_reset_content() {\n' + \ | |
| 'if (__reactive_block_reset) { __reactive_need_reset=true; return;};\n' + \ | |
| '__reactive_block_reset = true;\n' + \ | |
| '__reactive_need_reset = false;\n' + \ | |
| f'{control_var.js_get()}.inner_destructor();\n' + \ | |
| script.initial_pre_calc + '\n' + \ | |
| (f'document.getElementById({id_js_expression}).innerHTML = ' + js_rerender_expression + ';\n' | |
| if not self.self_enclosed else '') + \ | |
| f'{control_var.js_get()}.inner_post();\n' + \ | |
| '__reactive_block_reset = false;\n' + \ | |
| 'if (__reactive_need_reset) { __reactive_reset_content();};\n' + \ | |
| ';}\n' + \ | |
| f'{control_var.js_get()}.inner_post = function() {{\n{script.initial_post_calc}\n}};\n' + \ | |
| f'{control_var.js_get()}.inner_destructor = function() {{\n{script.destructor}\n}};\n' + \ | |
| '\n'.join(chain.from_iterable((f'{control_var.js_get()}.attachment_attribute_{attribute}_var_{hook.get_name()} = ' + \ | |
| hook.js_attach(change_attribute(id_js_expression, attribute, js_cond_exp, js_vaL_exp), True) + ';' \ | |
| for hook in _hooks) \ | |
| for attribute, (js_cond_exp, js_vaL_exp, _hooks) in all_attributes_js_expressions_and_hooks.items())) + \ | |
| '\n' + \ | |
| f'{control_var.js_get()}.inner_post();\n' + \ | |
| '__reactive_block_reset = false;\n' + \ | |
| 'if (__reactive_need_reset) { __reactive_reset_content();};\n' + \ |
As we did there, we need to add tracking bool variables and invoke recursively the rerender whenever the attachment was triggered.
The recursion is important, because there will be a recursion stack overflow event on cycles, which will indicate we(/the user) did something wrong.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels