liveBook · Manning

Completed event pattern

As explained in Effective Behavior-Driven Development

A pattern for waiting for an asynchronous operation to finish by receiving a completion event instead of repeatedly checking its status.

When an asynchronous operation takes time, repeatedly checking its status wastes effort. The completed event pattern waits for the resource to signal that the operation has finished. section 21.4.2 section 21.5

A practical approach:

  • Use a completion event when the resource provides one; it avoids a polling loop and can notify as soon as the operation completes. section 21.4.2 section 21.5
  • Keep an overall timeout: an operation may never complete, leaving the notification unreceived. section 21.4.2
  • For a resource without events that is used repeatedly, consider a façade that performs active waiting and exposes the result as a completion event. section 21.4.2

File changes

A file-system watcher can notify automation code when a file changes, avoiding repeated checks of its last-write time. section 21.4.2

How Effective Behavior-Driven Development covers it

How deep it goes
Defines event-based waiting, timeout needs, and façade use, without detailing event-handling internals.
Examples
Uses a file-system watcher notifying automation code when a file changes.
What it assumes
Assumes an operation may remain incomplete after its request returns and contrasts event waiting with polling.
What you can do after
Apply it by waiting for resource events, retaining a timeout, or exposing polling through a façade.
How it connects
Contrasts with Active Waiting and sits alongside Synchronous Testing as an approach to asynchronous resources.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.