slackline/stream/fetch

Runs a streamed reply on JavaScript, using promises. See slackline/stream for how a reply behaves.

let r =
  stream.new(client, channel: "C123")
  |> stream.in_thread(thread_ts)
  |> stream.to(user: "U123", team: "T123")
  |> fetch.open
fetch.text(r, "Looking at it")
use finished <- promise.await(fetch.finish(r, closing: ""))

Calls go out one at a time and in order. None of them block the caller.

Types

pub opaque type Reply

Values

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

Finishes the reply. closing is a last line to add, or “” for none. The promise resolves once every call is done.

pub fn open(builder: stream.Builder) -> Reply

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