Skip to content

Latest commit

 

History

History

drizzle-rxjs

RxJs Call Adapter · ci npm (scoped) GitHub license

RxJs call adapter implementation for Drizzle-HTTP.

Installation

Make sure we have the core module @Drizzle-Http/core installed.

npm i @drizzle-http/core
npm i @drizzle-http/rxjs-adapter

Usage

After adding the RxJsCallAdapterFactory to Drizzle instance, decorate your class or methods with @RxJs().
See the example below.

import { GET } from "@drizzle-http/core";
import { Param } from "@drizzle-http/core";
import { RxJs } from "@drizzle-http/rxjs-adapter";
import { DrizzleBuilder } from "@drizzle-http/core";
import { RxJsCallAdapterFactory } from "@drizzle-http/rxjs-adapter";

@RxJs()
class API {
  @GET('/{id}/projects')
  projects(@Param('id') id: string): Observable<Project[]> { }
}

const api = DrizzleBuilder
  .newBuilder()
  .baseUrl(addr)
  .addCallAdapterFactories(new RxJsCallAdapterFactory(/* optional: you can pass another adapter factory */))
  .build()
  .create(API)