A simple Quark to manage freeing/closing of objects after another limited-lifetime object is complete.
FreeAfter provides a simple mechanism to free or close any object after another limited-lifetime object is complete. It works by way of an Object:freeAfter
and Object:closeAfter
methods, plus type-specific overrides for the objects that are able to trigger a free/close.
In the context of this quark, "freeing" simply consists in calling the .free
method for the object in question. Likewise, "closing" consists in calling the .close
method.
Call .free
or .close
on the current object after another object is finished.
other |
Another limited-lifetime object. Any object which has a
|
Some valuable use-cases include:
Custom classes can provide support for .freeAfter and .closeAfter by defining an onDoAfter
method. It must take a single argument, a function to call after the object in question in finished.
In general, the func argument should NOT be called more than once.