__platform tag so the narrowing functions from platform narrowing can recover their platform-specific shapes.
Space
Every exposes the same interface regardless of platform:| Method | Description |
|---|---|
send(...content) | Send one or more content items into the conversation. |
edit(message, newContent) | Rewrite a previously-sent message. Sugar for send(edit(newContent, message)). |
unsend(message) | Retract a previously-sent message. Sugar for send(unsend(message)). |
startTyping() | Show a typing indicator. No-op if the platform doesn’t support it. |
stopTyping() | Hide the typing indicator. |
responding(fn) | Start a typing indicator, run fn, and stop the indicator when it completes — even if fn throws. |
getMessage(id) | Fetch a message by ID from the conversation. Throws UnsupportedError on platforms that don’t support it. |
rename(displayName) | Rename the chat. Sugar for send(rename(displayName)). |
avatar(input, options?) | Set or clear the chat avatar. Sugar for send(avatar(input, options?)). |
User
Users are minimal: an ID and a platform tag.user.schema.
Typing indicators
Manual
space.send(typing("start")) and space.send(typing("stop")) — see Typing indicators for the canonical form.
Automatic with responding
responding is the recommended pattern. It guarantees the typing indicator is cleared even if the inner function throws:
Creating a space
To start a new conversation, use platform narrowing to get a platform instance, then callspace.create(...) with the users:
space.get(id):
type: "dm" | "group" on iMessage — but it also satisfies the generic Space interface, so send(), startTyping(), and friends are always available.