How to use the @sanity/mutator.BufferedDocument function in @sanity/mutator

To help you get started, we’ve selected a few @sanity/mutator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / document-store / src / createObservableBufferedDocument.js View on Github external
const createInitialBufferedDocument = snapshot => {
    const bufferedDocument = new BufferedDocument(snapshot)
    bufferedDocument.onMutation = ({mutation, remote}) => {
      updates$.next({
        type: 'mutation',
        document: bufferedDocument.LOCAL,
        mutations: mutation.mutations,
        origin: remote ? 'remote' : 'local'
      })
    }

    bufferedDocument.onRebase = edge => {
      updates$.next({type: 'rebase', document: edge})
    }

    bufferedDocument.commitHandler = opts => {
      const {resultRev, ...mutation} = opts.mutation.params
      commits$.next({onSuccess: opts.success, onError: opts.failure, payload: mutation})
github sanity-io / sanity / packages / @sanity / base / src / datastores / document / buffered-doc / createObservableBufferedDocument.ts View on Github external
const createInitialBufferedDocument = snapshot => {
    const bufferedDocument = new BufferedDocument(snapshot)
    bufferedDocument.onMutation = ({mutation, remote}) => {
      updates$.next({
        type: 'mutation',
        document: bufferedDocument.LOCAL,
        mutations: mutation.mutations,
        origin: remote ? 'remote' : 'local'
      })
    }

    bufferedDocument.onRebase = edge => {
      updates$.next({type: 'rebase', document: edge})
    }

    bufferedDocument.commitHandler = opts => {
      const {resultRev, ...mutation} = opts.mutation.params
      commits$.next({onSuccess: opts.success, onError: opts.failure, mutation})

@sanity/mutator

A set of models to make it easier to utilize the powerful real time collaborative features of Sanity

MIT
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis