Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A wrapper function for dynamic modules that causes a placeholder to be shown during initialization
ResourceFunction["AsynchronousDynamicModule"][DynamicModule[…,Initialization⧴(init)]] returns a new DynamicModule that initializes the expression init asynchronously. During the initialization, a spinner will be shown and the content of the DynamicModule will not evaluate before the initialization has finished. | |
ResourceFunction["AsynchronousDynamicModule"][DynamicModule[…],placeholder] shows placeholder during initialization. | |
ResourceFunction["AsynchronousDynamicModule"][DynamicModule[…],placeholder,flag] uses the variable flag to determine if the initialization has finished. |
The following DynamicModule shows a pink box during the initialization because the inner dynamic causes an error message:
In[1]:= |
Out[1]= |
AsynchronousDynamicModule automatically fixes this problem:
In[2]:= |
Out[2]= |
The Print statement will not evaluate before the initialization finishes. All evaluation of the DynamicModule is prevented before the initialization has finished:
In[3]:= |
Out[3]= |
Any placeholder can be used to show progress of the initialization:
In[4]:= |
Out[4]= |
You can specify a dynamically updated variable that returns the content to its initialization state. This update action can then be reused in the content of the DynamicModule:
In[5]:= |
Out[5]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License