FreeAfter overview:
Filter:
FreeAfter/Guides (extension) | Control

FreeAfter overview
ExtensionExtension

An overview of the FreeAfter quark

Description

A simple Quark to manage freeing/closing of objects after another limited-lifetime object is complete.

Introduction

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.

Instance Methods

.freeAfter

.closeAfter

Call .free or .close on the current object after another object is finished.

Arguments:

other

Another limited-lifetime object. Any object which has a addDoAfter method is valid:

Examples

Use cases

Some valuable use-cases include:

Extending

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.