Skip to content

Commit

Permalink
docs: Add incorrect/correct snippets.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Oct 23, 2020
1 parent 20dfe5c commit 80267c2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/rules/no-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

This rule prevents the use of the static `create` function in `Observable`. Developers should use `new` and the constructor instead.

## Rule details

Examples of **incorrect** code for this rule:

```ts
const answers = Observable.create(subscriber => {
subscriber.next(42);
subscriber.next(54);
subscriber.complete();
});
```

Examples of **correct** code for this rule:

```ts
const answers = new Observable<number>(subscriber => {
subscriber.next(42);
subscriber.next(54);
subscriber.complete();
});
```

## Options

This rule has no options.

0 comments on commit 80267c2

Please sign in to comment.