liveBook · Manning

Wait method

As explained in API Design Patterns

A wait method is a custom API method that holds a request until an operation is resolved or rejected.

A wait method is a custom API method that holds a request until a long-running operation is resolved or rejected. It offers an alternative to client-controlled polling, which repeatedly retrieves an operation resource until its done field is true. section 10.3.3

Choose between the two resolution patterns according to where control and request cost should reside:

  • Use polling when the client needs to control request frequency, stop checking, or define how timely the result must be. section 10.3.3

Creating a chat room and waiting

CreateChatRoom returns an Operation. The client passes its ID to WaitOperation, then reads operation.result as the completed ChatRoom.

How API Design Patterns covers it

How deep it goes
Defines the method shape and contrasts it with polling, but does not detail server-side waiting behavior.
Examples
Uses CreateChatRoom, GetOperation, WaitOperation, and a typed Operation<ChatRoom, CreateChatRoomMetadata>.
What it assumes
Assumes familiarity with long-running operations, operation IDs, typed results, and the standard GetOperation method.
What you can do after
Apply it via WaitOperation to obtain a completed operation result without writing a client polling loop.
How it connects
Connects long-running operations, polling, promises, operation resources, and custom API methods.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.