untilCalled top-level property

InvocationLoader untilCalled

Returns a future Invocation that will complete upon the first occurrence of the given invocation.

Usage of this is as follows:

cat.eatFood("fish");
await untilCalled(cat.chew());

In the above example, the untilCalled(cat.chew()) will complete only when that method is called. If the given invocation has already been called, the future will return immediately.

Implementation

InvocationLoader get untilCalled {
  _untilCalledInProgress = true;
  return <T>(T _) {
    _untilCalledInProgress = false;
    return _untilCall!.invocationFuture;
  };
}