Skip to content

Commit

Permalink
feat: updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Manthan Ankolekar committed Jul 12, 2023
1 parent 2d4f051 commit af6a064
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,36 @@ export class App implements OnInit {
bootstrapApplication(App);
```

**switchMapTo** -
**switchMapTo** - Projects each source value to the same Observable which is flattened multiple times with switchMap in the output Observable.

```typescript
import 'zone.js/dist/zone';
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { bootstrapApplication } from '@angular/platform-browser';
import { fromEvent, switchMapTo, interval } from 'rxjs';

@Component({
selector: 'my-app',
standalone: true,
imports: [CommonModule],
template: `
<h1>switchMapTo operator</h1>
`,
})
export class App implements OnInit {
ngOnInit() {
const clicks = fromEvent(document, 'click');
const result = clicks.pipe(switchMapTo(interval(1000)));
result.subscribe(x => console.log(x));
}
}

bootstrapApplication(App);
```

[Stackblitz Example Link](https://stackblitz.com/edit/stackblitz-starters-wbj1xt?file=src%2Fmain.ts)

**window** -

```typescript
Expand Down

0 comments on commit af6a064

Please sign in to comment.