Tinylib
DiscoverDocsSign in
Sign in
Tinylib
AboutDiscoverDocsMake an appPricingTermsPrivacyDeveloper TermsContact

Start

  • Quickstart
  • How Tinylib works

Guides

  • Data
  • Rooms and rules
  • Games
  • Friends
  • Places and links
  • Reminders and notifications
  • Publishing
  • Errors and offline
  • Platforms

Client API

  • tinylib
  • tinylib.data
  • tinylib.rooms
  • tinylib.invitations
    • list()
    • handle()
    • Invitation
  • tinylib.friends
  • tinylib.places
  • tinylib.reminders
  • Types
  • tinylib-sdk/kits

Rules API

  • Kinds
  • ctx

Reference

  • tinylib.json
  • Command line
  • Limits

Plain text

  • llms.txt
  • llms-full.txt

tinylib.invitations

While your app is open, Tinylib shows its own sheet for each invitation to it, except those you take with handle. Outside your app, Tinylib notifies the user of every invitation.

tinylib.invitations.list()

tinylib.invitations.list(): Promise<Invitation[]>
Lists the user's invitations to your app's rooms, including those a handle shows.
JavaScript
const invitations = await tinylib.invitations.list()

Returns

Promise<Invitation[]>
The invitations, newest first. Always empty for a guest.

Rejects with

offline

tinylib.invitations.handle()

tinylib.invitations.handle(pick: (invitation: Invitation) => boolean, fn: (invitations: Invitation[]) => void): () => void
Hands the invitations pick selects to your app to show, in place of Tinylib's sheet. Calls fn with them at once and again each time the user's invitations to your app change. Offer block and report for each sender.
JavaScript
const rematch = document.querySelector('#rematch') const stop = tinylib.invitations.handle( (invitation) => invitation.rematchOf === gameId, (invitations) => { rematch.hidden = invitations.length === 0 }, )

Parameters

pick(invitation: Invitation) => boolean
Called with each invitation. Returns true for one your app shows.
fn(invitations: Invitation[]) => void
Called with every invitation pick returned true for, possibly none.

Returns

() => void
A function that stops the calls and gives the invitations back to Tinylib's sheet.

Throws

TypeError
When pick or fn isn't a function.

Invitation

interface Invitation
An invitation to one of your app's rooms.

Properties

idstringread-only
The invitation's id.
fromMemberread-only
The member who sent the invitation, a Member.
kindstringread-only
The room's kind.
namestring | nullread-only
The room's name, or null when the rules haven't set one.
atnumberread-only
When the invitation was sent, in milliseconds on Tinylib's clock.
rematchOfstring | nullread-only
The id of the room this one is a rematch of, or null.

Methods

accept()
Joins the room and removes the invitation.
dismiss()
Declines the invitation and removes it.

invitation.accept()

invitation.accept(): Promise<{ id: string }>
Joins the room and removes the invitation. It doesn't open the room.
JavaScript
const { id } = await invitation.accept() tinylib.places.go(`game/${id}`)

Returns

Promise<{ id: string }>
The room's id, as { id }.

Rejects with

not_found
When the invitation is gone, or its sender has left the room or may no longer invite.
refused
When the user or a member has blocked the other, or the user is a guest.
limit
When the user is already in 50 rooms of your app, or the room already has 64 members.
offline

invitation.dismiss()

invitation.dismiss(): Promise<void>
Declines the invitation and removes it.
JavaScript
await invitation.dismiss()

Rejects with

refused
When the user is a guest.
offline
Previoustinylib.roomsNexttinylib.friends

On this page

  • list()
  • handle()
  • Invitation
  • accept()
  • dismiss()