LiveFlow.Collaboration.User (LiveFlow v0.4.0)

Copy Markdown View Source

Represents a user in a collaborative flow session.

Fields

  • :id - Unique user identifier (required)
  • :name - Display name (auto-generated if not provided)
  • :color - Cursor/highlight color as hex string (auto-generated if not provided)

Examples

iex> user = LiveFlow.Collaboration.User.new("user_123")
iex> user.id
"user_123"

iex> user = LiveFlow.Collaboration.User.new("user_123", name: "Alice", color: "#ef4444")
iex> user.name
"Alice"

Summary

Functions

Creates a new user with the given ID.

Returns the user data as a map suitable for Presence metadata.

Types

t()

@type t() :: %LiveFlow.Collaboration.User{
  color: String.t(),
  id: String.t(),
  name: String.t()
}

Functions

new(id, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: t()

Creates a new user with the given ID.

Options:

  • :name - Display name. Defaults to "User N" where N is derived from the ID.
  • :color - Hex color string. Defaults to a color deterministically chosen from the ID.

to_presence_meta(user)

@spec to_presence_meta(t()) :: map()

Returns the user data as a map suitable for Presence metadata.