provideStreamResource()
provideStreamResource is the provider factory that registers stream-resource in Angular's dependency injection system. Call it once inside bootstrapApplication (or an ApplicationConfig) to configure the transport and any global defaults used by every streamResource in your app.
This is the single configuration point for the entire library. Rather than configuring each resource individually, you declare your transport here and every streamResource call throughout the app inherits it automatically.
import { bootstrapApplication } from '@angular/platform-browser';
import {
provideStreamResource,
FetchStreamTransport,
} from '@cacheplane/stream-resource';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, {
providers: [
provideStreamResource({
transport: FetchStreamTransport,
}),
],
});Global configuration
| Option | Type | Description |
|--------|------|-------------|
| transport | Type<StreamTransport> | The transport class to inject when resources request StreamTransport. Required. |
Swapping transports by environment
Because provideStreamResource accepts a class token, you can vary the transport based on your environment without touching any component code:
// main.ts — production
provideStreamResource({ transport: FetchStreamTransport })
// main.spec.ts / TestBed — tests
provideStreamResource({ transport: MockStreamTransport })Swap FetchStreamTransport for MockStreamTransport (or any custom class
implementing the StreamTransport interface) to change the transport for all
resources at once — useful for testing or SSR.