@w11k/rx-ninja

Build Status npm version

rx-ninja

Utilities for RxJS. Provides additional operators as well as tslint rules to avoid common mistakes.

API Documentation

Please see API documentation

Operators

Please use the API documentation for an always up-to-date list of all included operators. The API documentation also contains detailed descriptions, examples and marble diagrams.

TSLint rules

Installation

Adjust your tslint.json

{
"rulesDirectory": [
"node_modules/@w11k/rx-ninja/dist/bundle/tslint_rules"
],
"rules": {
"rx-ninja-subscribe-takeuntil": true,
"rx-ninja-subscribe-in-subscribe": true
}
}

Run tslint with type info

tslint -p tsconfig.json -t verbose

Rule descriptions

rx-ninja-subscribe-takeuntil

This rule triggers when Observable#subscribe() is called and then enforces that

  • .pipe() is called directly before .subscribe()
  • and that either takeUntil() or one of a specified finalizer operators is called as the last pipe operator

You can filter the files where this rules applies with fileSuffix and excludedFileSuffix.

Configuration:

"rx-ninja-subscribe-takeuntil": [
true,
{
"finalizer": [
"takeUntil",
"customOperator",
"anotherOperator"
],
"fileSuffix": [
".ts"
],
"excludedFileSuffix": [
".spec.ts",
".test.ts"
]
}
]

rx-ninja-subscribe-in-subscribe

This rule triggers when Observable#subscribe() is called inside another Observable#subscribe() call, e.g.

import {of} from "rxjs";

of(1).subscribe(() => {
of(2).subscribe(); // <-- error
});

Utilities

Patrons

❤️ W11K - The Web Engineers

❤️ theCodeCampus - Trainings for Angular and TypeScript

Thanks

  • Diagram generation from RxJS

Generated using TypeDoc