Scoping
Since Module
adds the Temporal
attribute to your symbols, it is unclear when and how your dynamic symbols will be purged from the Kernel. Therefore, use LeakyModule
to scope all dynamic symbols.
You can clean them up using ClearAll
after a notebook has been closed or a cell has been destroyed. EventHandler
methods are applicable to ResultCell, EvaluationNotebook, or even WindowObj.
info
Since WL 14.2 using LeakyModule
is unnecessary. The native Module
will do the job.