How to use the @sanity/observable/operators/filter.filter 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 / client / src / sanityClient.js View on Github external
request(options) {
    const observable = this._requestObservable(options).pipe(
      filter(event => event.type === 'response'),
      map(event => event.body)
    )

    return this.isPromiseAPI() ? toPromise(observable) : observable
  }
})
github sanity-io / sanity / packages / @sanity / client / src / data / dataMethods.js View on Github external
getDocuments(ids) {
    const options = {uri: this.getDataUrl('doc', ids.join(',')), json: true}
    const observable = this._requestObservable(options).pipe(
      filter(isResponse),
      map(event => {
        const indexed = indexBy(event.body.documents || [], doc => doc._id)
        return ids.map(id => indexed[id] || null)
      })
    )

    return this.isPromiseAPI() ? toPromise(observable) : observable
  },
github sanity-io / sanity / packages / @sanity / client / src / assets / assetsClient.js View on Github external
query.sourceName = source.name
      query.sourceUrl = source.url
    }
    const observable = this.client._requestObservable({
      method: 'POST',
      timeout: options.timeout || 0,
      uri: `/assets/${assetEndpoint}/${dataset}`,
      headers: options.contentType ? {'Content-Type': options.contentType} : {},
      query,
      body
    })

    return this.client.isPromiseAPI()
      ? observable
          .pipe(
            filter(event => event.type === 'response'),
            map(event => toDocument(event.body))
          )
          .toPromise()
      : observable
  },

@sanity/observable

[deprecated] This package exists for legacy reasons only

MIT
Latest version published 3 years ago

Package Health Score

78 / 100
Full package analysis