@bzr/bazaar
    Preparing search index...

    Class BazaarApp

    The primary class of the Bazaar JS SDK to help you more easily build web apps with Bazaar.

    Index

    Constructors

    Properties

    collections: CollectionsAPI

    Access to the collections API

    files: FilesAPI

    Access to the files/blob storage API

    monetization: MonetizationAPI

    Access to the monetization API

    Access to the organizations API

    permissions: PermissionsAPI

    Access to the permissions API

    social: SocialAPI

    Access to the social API

    Methods

    • Gets a collection interface (API access to the specified collection)

      Type Parameters

      • T extends Doc = {
            id: string;
            [key: string]: unknown;
            [key: number]: unknown;
            [key: symbol]: unknown;
        }

      Parameters

      • collectionName: string

        The name of the collection to create the interface for.

      • OptionalcollectionOptions: CollectionOptions

        An optional object for specifying an onCreate hook. The onCreate hook sets up a collection when it is created (e.g., to set up permissions)

      Returns CollectionAPI<T>

    • Checks if the user is logged in. i.e. if an access token is in local storage.

      Returns boolean

    • Opens a pop-up window to perform OAuth login. Will fallback to redirect login if pop-up fails to open, if options.type is not popup (meaning an app has explicitly opted out of falling back to redirect login)

      Settles when the login finished or the user closed the pop-up: check isLoggedIn.

      Parameters

      Returns Promise<void>

    • Logs out a user. Deletes the access token from local storage and reloads the page.

      Returns void

    • Sets a callback function an app can run when it connects or re-connects to the API.

      Parameters

      Returns void

    • Sets a callback function an app can run when the server refuses the user.

      e.g. Invalid access token. Network and server failures don't count: the connection keeps trying, and restores subscriptions once it's back.

      Parameters

      • f: (bzr: BazaarApp, message: string) => Promise<void>

      Returns void

    • Sets a callback function an app can run when a user has successfully logged in.

      e.g. Set state, redirect, etc.

      Parameters

      Returns void

    • Sets a callback function an app can run a login error occurs.

      e.g. Authorization code is invalid

      Parameters

      • f: (bzr: BazaarApp, message: string) => Promise<void>

      Returns void