Sanity Library Reference Docs
    Preparing search index...

    Interface DocumentPreviewStoreBeta

    The document preview store supports subscribing to content for previewing purposes. Documents observed by this store will be kept in sync and receive real-time updates from all collaborators, but has no support for optimistic updates, so any local edits will require a server round-trip before becoming visible, which means this store is less suitable for real-time editing scenarios.

    interface DocumentPreviewStore {
        observeDocumentTypeFromId: (
            id: string,
            apiConfig?: ApiConfig,
            perspective?: StackablePerspective[],
        ) => Observable<string>;
        observeForPreview: ObserveForPreviewFn;
        observePaths: ObservePathsFn;
        unstable_observeDocument: (
            id: string,
            clientConfig?: ObserveDocumentAPIConfig,
        ) => Observable<SanityDocument>;
        unstable_observeDocumentIdSet: (
            filter: string,
            params?: QueryParams,
            options?: {
                apiVersion?: string;
                insert?: "sorted" | "prepend" | "append";
            },
        ) => Observable<DocumentIdSetObserverState>;
        unstable_observeDocumentPairAvailability: (
            id: string,
            options?: { version?: string },
        ) => Observable<DraftsModelDocumentAvailability>;
        unstable_observeDocuments: (
            ids: string[],
            clientConfig?: ObserveDocumentAPIConfig,
        ) => Observable<SanityDocument[]>;
        unstable_observeDocumentStackAvailability: (
            id: string,
            perspectiveStack: StackablePerspective[],
        ) => Observable<DocumentStackAvailability[]>;
        unstable_observePathsDocumentPair: <
            T extends SanityDocument = SanityDocument,
        >(
            id: string,
            paths: PreviewPath[],
            options?: { version?: string },
        ) => Observable<DraftsModelDocument<T>>;
    }
    Index

    Properties

    observeDocumentTypeFromId: (
        id: string,
        apiConfig?: ApiConfig,
        perspective?: StackablePerspective[],
    ) => Observable<string>
    observeForPreview: ObserveForPreviewFn
    observePaths: ObservePathsFn
    unstable_observeDocument: (
        id: string,
        clientConfig?: ObserveDocumentAPIConfig,
    ) => Observable<SanityDocument>

    Observe a complete document with the given ID

    unstable_observeDocumentIdSet: (
        filter: string,
        params?: QueryParams,
        options?: { apiVersion?: string; insert?: "sorted" | "prepend" | "append" },
    ) => Observable<DocumentIdSetObserverState>

    Observes a set of document IDs that matches the given groq-filter. The document ids are returned in ascending order and will update in real-time Whenever a document appears or disappears from the set, a new array with the updated set of IDs will be pushed to subscribers. The query is performed once, initially, and thereafter the set of ids are patched based on the appear and disappear transitions on the received listener events. This provides a lightweight way of subscribing to a list of ids for simple cases where you just want to subscribe to a set of documents ids that matches a particular filter.

    Type declaration

      • (
            filter: string,
            params?: QueryParams,
            options?: { apiVersion?: string; insert?: "sorted" | "prepend" | "append" },
        ): Observable<DocumentIdSetObserverState>
      • Parameters

        • filter: string

          A groq filter to use for the document set

        • Optionalparams: QueryParams

          Parameters to use with the groq filter

        • Optionaloptions: { apiVersion?: string; insert?: "sorted" | "prepend" | "append" }

          Options for the observer

          • OptionalapiVersion?: string
          • Optionalinsert?: "sorted" | "prepend" | "append"

            Where to insert new items into the set. Defaults to 'sorted' which is based on the lexicographic order of the id

        Returns Observable<DocumentIdSetObserverState>

    unstable_observeDocumentPairAvailability: (
        id: string,
        options?: { version?: string },
    ) => Observable<DraftsModelDocumentAvailability>
    unstable_observeDocuments: (
        ids: string[],
        clientConfig?: ObserveDocumentAPIConfig,
    ) => Observable<SanityDocument[]>

    Observe a list of complete documents with the given IDs

    unstable_observeDocumentStackAvailability: (
        id: string,
        perspectiveStack: StackablePerspective[],
    ) => Observable<DocumentStackAvailability[]>
    unstable_observePathsDocumentPair: <T extends SanityDocument = SanityDocument>(
        id: string,
        paths: PreviewPath[],
        options?: { version?: string },
    ) => Observable<DraftsModelDocument<T>>