slackline/stream/httpc

Runs a streamed reply on Erlang. Each reply gets its own process. See slackline/stream for how a reply behaves.

let assert Ok(r) =
  stream.new(client, channel: "C123")
  |> stream.in_thread(thread_ts)
  |> stream.to(user: "U123", team: "T123")
  |> httpc.open
httpc.text(r, "Looking at it")
let assert Ok(finished) = httpc.finish(r, closing: "")

Types

pub opaque type Reply

Values

pub fn finish(
  reply: Reply,
  closing closing: String,
) -> Result(stream.Finished, Nil)

Finishes the reply and waits until every call is done. closing is a last line to add, or “” for none. Returns an error if the reply was already finished.

pub fn open(
  builder: stream.Builder,
) -> Result(Reply, actor.StartError)

Starts the reply. Nothing is posted until the reply has something to show.

pub fn task(reply: Reply, task: stream.Task) -> Nil

Adds a task to the reply’s plan, or updates the task with the same id.

pub fn text(reply: Reply, text: String) -> Nil

Sets the reply’s text. Pass the whole text so far, not just the new part.

pub fn title(reply: Reply, title: String) -> Nil

Sets the plan’s title. It shows up once the reply has a task.

✨ Search Document