Skip to content

Instantly share code, notes, and snippets.

View gmcabrita's full-sized avatar

Gonçalo Mendes Cabrita gmcabrita

View GitHub Profile
package examples
import (
"github.com/XANi/loremipsum"
"github.com/go-chi/chi/v5"
. "github.com/starfederation/datastar-dev/site/shared"
datastar "github.com/starfederation/datastar/sdk/go"
"math/rand/v2"
"net/http"
"time"
defmodule Task do
defp await_one(tasks, timeout \\ 5_000) when is_list(tasks) do
awaiting =
Map.new(tasks, fn %Task{ref: ref, owner: owner} = task ->
if owner != self() do
raise ArgumentError, invalid_owner_error(task)
end
{ref, true}
end)