Skip to content

Commit

Permalink
Read global element variable at creation time of the promise,… (#1566)
Browse files Browse the repository at this point in the history
* Read global element variable at creation time of the promise, not during resolve.

At resolve time, the global variable might already have changed.

* Restore original formatting to be able to track what was changed

---------

Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
  • Loading branch information
kalanzun and adam-urbanczyk committed Apr 29, 2024
1 parent 3837cc5 commit 5522037
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cadquery/occ_impl/jupyter_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
TEMPLATE_RENDER
+ """
function load_and_render(parent_element)
{{
new Promise(
function(resolve, reject)
{{
Expand All @@ -148,10 +150,12 @@
}} else {{ resolve() }};
}}
).then(() => {{
var parent_element = {element};
var data = {data};
render(data, parent_element, {ratio});
}});
}}
load_and_render({element});
"""
)

Expand Down

0 comments on commit 5522037

Please sign in to comment.