Skip to content

1.9.0

Compare
Choose a tag to compare
@rmconsole-wf rmconsole-wf released this 26 Oct 23:21

Changes

The Disposable.awaitBeforeDispose() API was intended to provide consumers with a way to delay disposal such that certain tasks could be completed before managed instances/dependencies were torn down. The intention was that the Disposable APIs themselves would remain usable, even after dispose() was called, so long as disposal hadn't started. Unfortunately, Disposable.isDisposedOrDisposing would begin returning true as soon as dispose() was called, and our Disposable APIs would throw if called after that point.

To address this, we've done a few things:

  • Changed the logic behind isDisposing (and consequently isDisposedOrDisposing) such that it only becomes true when disposal has actually started. Based on current usages of this API, we do not expect any breakages from this change.

  • Added a isOrWillBeDisposed getter – this should be used by consumers to guard their own public APIs so as to prevent additional tasks from being started. It will be true as soon as disposal is requested (i.e. as soon as dispose() is called).

  • Deprecated isDisposing and isDisposedOrDisposing – the newly added getter above should be sufficient for consumers to guard their own APIs.

  • Added a onWillDispose() lifecycle hook that, like onDispose(), can be overridden by extenders of Disposable. This handler will be called as soon as disposal is requested (i.e. dispose() is called) but before disposal has started. The Future returned from this method will be awaited, then all Futures registered via awaitBeforeDispose() will be awaited, and only then when disposal actually begin.

The result of these changes are that you may now actually delay disposal via awaitBeforeDispose() (as was originally intended) and via onWillDispose(). All of the Disposable APIs will remain usable up until disposal actually begins.

Deprecations

The following two getters on the Disposable class have been deprecated:

  • isDisposing
  • isDisposedOrDisposing

Consumers should now use Disposable.isOrWillBeDisposed – it will be true as soon as disposal is requested (i.e. when dispose() is called) and will remain true while the instance is disposing, and when it has completed disposal.

Pull Requests

  • #66 WP-5391 Add "disposal imminent" step prior to disposal
  • #68 WP-5038 Release w_common 1.9.0

Notes created on Thursday, October 26 11:21 PM UTC