// only works within a module // has mild race conditions sclass SnippetInstaCache is AutoCloseable { // snippet ID to text SS texts = syncMap(); AutoCloseable updater; *() { updater = dm_onSnippetEdited(voidfunc(S id) { texts.put(id, loadSnippet(id)); }); } S getSnippetText(S snippetID) { ret texts.get(fSI(snippetID)); } close { dispose updater; } }