Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

OnError

OnError: function

Type declaration

    • (error: Error): any
    • Parameters

      • error: Error

      Returns any

OnResult

OnResult<Model>: function

Type parameters

  • Model

Type declaration

    • (doc: Doc<Model> | undefined): any
    • Parameters

      • doc: Doc<Model> | undefined

      Returns any

Functions

onGet

  • Subscribes to the diven document.

    import { onGet, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    onGet(users, '00sHm46UWKObv2W7XK9e', sasha => {
      console.log(sasha.ref.id)
      //=> '00sHm46UWKObv2W7XK9e'
      console.log(sasha.data)
      //=> { name: 'Sasha' }
    })

    Type parameters

    • Model

    Parameters

    • ref: Ref<Model>

      The reference to the document

    • onResult: OnResult<Model>

      The function which is called with the document when the initial fetch is resolved or the document updates.

    • Optional onError: OnError

      The function is called with error when request fails.

    Returns function

    Function that unsubscribes the listener from the updates

      • (): void
      • Returns void

  • Subscribes to the diven document.

    import { onGet, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    onGet(users, '00sHm46UWKObv2W7XK9e', sasha => {
      console.log(sasha.ref.id)
      //=> '00sHm46UWKObv2W7XK9e'
      console.log(sasha.data)
      //=> { name: 'Sasha' }
    })

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The document collection

    • id: string

      The document id

    • onResult: OnResult<Model>

      The function which is called with the document when the initial fetch is resolved or the document updates.

    • Optional onError: OnError

      The function is called with error when request fails.

    Returns function

    Function that unsubscribes the listener from the updates

      • (): void
      • Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc