MetadataCache: how to cancel callback (code example please)

I want to add some callbacks to a MetadataCache in an load method and then cancel it in an unload method. Could someone please post some code that actually compiles and runs?

The on method registers the callback and I have got that working. Presumably the off method cancels the callback somehow, but it is completely undocumented, so how do I make it work?

ok, I have found that `MetadataCache.on()` returns an `EventRef`, and I can pass the `EventRef` to `MetadataCache.off()', which compiles, but does not seem to cancel the callback.

`MetadataCache.offref(theEventRef)` seems to be the answer.

From looking at lots of random documentation.