Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

onAll

  • onAll<Model>(collection: Collection<Model>, onResult: function, onError?: undefined | function): function
  • Subscribes to all documents in a collection.

    import { onAll, collection } from 'typesaurus'
    
    type User = { name: string }
    const users = collection<User>('users')
    
    onAll(users, allUsers => {
      console.log(allUsers.length)
      //=> 420
      console.log(allUsers[0].ref.id)
      //=> '00sHm46UWKObv2W7XK9e'
      console.log(allUsers[0].data)
      //=> { name: 'Sasha' }
    })

    Type parameters

    • Model

    Parameters

    • collection: Collection<Model>

      The collection to get all documents from

    • onResult: function

      The function which is called with all documents array when the initial fetch is resolved or the collection updates.

        • (docs: Doc<Model>[]): any
        • Parameters

          • docs: Doc<Model>[]

          Returns any

    • Optional onError: undefined | function

      The function is called with error when request fails.

    Returns function

      • (): 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