Cables v0.1.1 Cables.Handler behaviour View Source
Handlers specify how to consume response data.
The handler flow starts with init/3
being called and returning the initial state or an error. In init
,
additional data can be sent with the request by using Cabels.send_data/2
and Cabels.send_final_data/2
.
After getting the new state we wait until we recieve the headers. handle_headers/3
will be called with the
status, headers and the state taken from init
. A new state should be returned.
After processing the headers, Cables will loop with handle_data/2
until there is no more response data. Each call to handle_data
should return a new state for the loop.
After all response data is recieved, handle_finish/1
will be called with the state from handle_data
to finish any processing.