Function Repository Resource:

RunAfterLoading

Source Notebook

Evaluate an expression when a package finishes loading

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["RunAfterLoading"][code,"context`"]

creates an event handler that evaluates code when "context`" finishes loading.

Examples

Basic Examples (2) 

Print a message when a context finishes loading:

In[1]:=
ResourceFunction["RunAfterLoading"][
 Print[Length[Names["Notation`*"]], " symbols loaded in Notation`."], "Notation`"]
Out[1]=
In[2]:=
Needs["Notation`"]

Get the load timing for a package:

In[3]:=
ResourceFunction["RunBeforeLoading"][$start = Now, "NeuralNetworks`"]
Out[3]=
In[4]:=
ResourceFunction["RunAfterLoading"][$end = Now, "NeuralNetworks`"]
Out[4]=
In[5]:=
NetModel["LeNet Trained on MNIST Data"]
Out[5]=
In[6]:=
$end - $start
Out[6]=

Scope (2) 

Retrieve the ResourceFunction:

In[7]:=
ResourceFunction["RunAfterLoading"]
Out[7]=

Retrieve the ResourceObject:

In[8]:=
ResourceObject["RunAfterLoading"]
Out[8]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 17 August 2018

Related Resources

License Information