How to use the @sanity/observable.of 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 / desk-tool / src / pane / EditorWrapper.js View on Github external
.catch(error =>
        Observable.of({
          type: 'error',
          message: `An error occurred while attempting to delete document.
        This usually means that you attempted to delete a document that other documents
        refers to.`,
          error
        })
      )
github sanity-io / sanity / packages / @sanity / base / src / preview / PreviewSubscriber.js View on Github external
subscribe(value, type, fields) {
    this.unsubscribe()

    const viewOptions = this.props.ordering
      ? {ordering: this.props.ordering}
      : {}

    const visibilityOn$ = Observable.of(!document.hidden)
      .merge(visibilityChange$.map(event => !event.target.hidden))

    const inViewport$ = intersectionObservableFor(this._element)
      .map(event => event.isIntersecting)

    this.subscription = visibilityOn$
      .distinctUntilChanged()
      .switchMap(isVisible => (isVisible ? inViewport$ : Observable.of(false)))
      .distinctUntilChanged()
      .switchMap(isInViewport => {
        return isInViewport
          ? observeForPreview(value, type, fields, viewOptions)
          : Observable.of(null)
      })
      .subscribe(result => {
        if (result) {
github sanity-io / sanity / packages / @sanity / base / src / preview / PreviewSubscriber.js View on Github external
      .switchMap(isVisible => (isVisible ? inViewport$ : Observable.of(false)))
      .distinctUntilChanged()
github sanity-io / sanity / packages / @sanity / base / src / preview / PreviewSubscriber.js View on Github external
.switchMap(isInViewport => {
        return isInViewport
          ? observeForPreview(value, type, fields, viewOptions)
          : Observable.of(null)
      })
      .subscribe(result => {

@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