Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Threads

Threads is an API module for managing Textile threads

Threads are distributed sets of encrypted files between peers governed by build-in or custom Schemas.

Thread type controls read (R), annotate (A), and write (W) access:

private --> initiator: RAW, whitelist: readonly --> initiator: RAW, whitelist: R public --> initiator: RAW, whitelist: RA open --> initiator: RAW, whitelist: RAW

Thread sharing style controls if (Y/N) a thread can be shared:

notshared --> initiator: N, whitelist: N inviteonly --> initiator: Y, whitelist: N shared --> initiator: Y, whitelist: Y

extends

API

Hierarchy

  • API
    • Threads

Index

Constructors

constructor

Properties

schemas

schemas: Schemas

snapshots

snapshots: Snapshots

Methods

add

  • add(name: string, schema?: string | object, key?: undefined | string, type?: ThreadType, sharing?: ThreadSharing, whitelist?: string[]): Promise<Thread>
  • Adds and joins a new thread

    Parameters

    • name: string

      The name of the new thread

    • Optional schema: string | object

      Schema ID for the new thread

    • Optional key: undefined | string

      A locally unique key used by an app to identify this thread on recovery

    • Optional type: ThreadType

      The type of thread, must be one of 'private' (default), 'read_only', 'public', or 'open'

    • Optional sharing: ThreadSharing

      The sharing style of thread, must be one of 'notshared' (default), 'invite_only', or 'shared'

    • Optional whitelist: string[]

      An array of contact addresses. When supplied, the thread will not allow additional peers, useful for 1-1 chat/file sharing or private threads.

    Returns Promise<Thread>

    The newly generated thread info

addOrUpdate

  • addOrUpdate(thread: string, info: Thread): Promise<void>
  • Adds or updates a thread directly, usually from a backup

    Parameters

    • thread: string

      ID of the thread

    • info: Thread

      Thread object

    Returns Promise<void>

get

  • get(thread: string): Promise<Thread>
  • Retrieve a thread by ID

    Parameters

    • thread: string

      ID of the thread

    Returns Promise<Thread>

    A thread object

getByKey

  • getByKey(key: string): Promise<undefined | Thread>
  • Retrieve a thread by Key

    Parameters

    • key: string

      Key of the thread

    Returns Promise<undefined | Thread>

    A thread object

getByName

  • getByName(name: string): Promise<Thread[]>
  • Retrieve threads by Name

    Parameters

    • name: string

      Name of the thread

    Returns Promise<Thread[]>

    An array thread objects

list

peers

  • List all peers in a thread

    Parameters

    • thread: string

      ID of the thread (default is 'default').

    Returns Promise<ContactList>

    An array of thread contacts

remove

  • remove(thread: string): Promise<boolean>
  • Leave and remove a thread by ID

    Parameters

    • thread: string

      ID of the thread

    Returns Promise<boolean>

    Whether the thread removal was successfull

removeByKey

  • removeByKey(key: string): Promise<boolean>
  • Leave and remove a thread by Key

    Parameters

    • key: string

      thread.key of the thread

    Returns Promise<boolean>

    Whether the thread removal was successfull

rename

  • rename(thread: string, name: string): Promise<boolean>
  • Renames a thread

    Note: Only initiators can rename a thread.

    Parameters

    • thread: string

      ID of the thread

    • name: string

      New name for the thread

    Returns Promise<boolean>

    Whether the rename was successfully