JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q71564F
  • License MIT

RxJs call adapter for Drizzle-HTTP

Package Exports

  • @drizzle-http/rxjs-adapter
  • @drizzle-http/rxjs-adapter/package.json

Readme

RxJs Call Adapter · ci npm (scoped) GitHub license

RxJs call adapter implementation for Drizzle-HTTP.

Installation

The main package, Drizzle-Http, already contains this module.
If you are installing each package individually, make sure to install first @Drizzle-Http/core with: npm i @drizzle-http/core

NPM

npm i @drizzle-http/rxjs-adapter

Yarn

yarn add @drizzle-http/rxjs-adapter

Usage

class API {
  @GET('/{id}/projects')
  @RxJs()
  getRx(@Path('id') id: string): Observable<TestResult<TestId>> {
    return theTypes(Observable, TestResult)
  }
}

const api = DrizzleBuilder.newBuilder()
  .baseUrl(addr)
  .addCallAdapterFactories(RxJsCallAdapterFactory.DEFAULT)
  .build()
  .create(API)

There are 3 things you need to do in order to enable RxJs return type for you API calls:

  • Add RxJsCallAdapterFactory to your Drizzle instance.
  • Your method return type must be: Observable<V>. Import the Observable from RxJs.
  • Add: return theTypes(Observable) in the method body. This way, Drizzle knows the return handledType during the setup and can set the RxJsCallAdapter for the request.
    If you don't want to use the theTypes(..) function, use the decorator @RxJs() on the method. It's the same.