Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow protection from race conditioning of hook attachments. #13

Open
Tal500 opened this issue Sep 5, 2021 · 0 comments
Open

Allow protection from race conditioning of hook attachments. #13

Tal500 opened this issue Sep 5, 2021 · 0 comments

Comments

@Tal500
Copy link
Owner

Tal500 commented Sep 5, 2021

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

'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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant