How to use the @sanity/observable/multicast function in @sanity/observable

To help you get started, we’ve selected a few @sanity/observable 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 / form-builder / src / sanity / uploads / uploadQueue.js View on Github external
// @flow
import Multicast from '@sanity/observable/multicast'
import Observable from '@sanity/observable'

import {uploadImageAsset} from '../inputs/client-adapters/assets'

const uploadRequests$ = new Multicast

const CONCURRENCY = 4

const registry = []
export function createUploadId(file: File): number {
  const id = registry.length
  const events = new Multicast
  registry[id] = {
    file,
    events$: events.asObservable().do({
      complete: () => {
        registry[id] = null
      }}),
    _multicast: events
  }
  return id
github sanity-io / sanity / packages / @sanity / form-builder / src / sanity / uploads / uploadQueue.js View on Github external
export function createUploadId(file: File): number {
  const id = registry.length
  const events = new Multicast
  registry[id] = {
    file,
    events$: events.asObservable().do({
      complete: () => {
        registry[id] = null
      }}),
    _multicast: events
  }
  return id
}

@sanity/observable

[deprecated] This package exists for legacy reasons only

MIT
Latest version published 4 years ago

Package Health Score

78 / 100
Full package analysis