Skip to content

Commit

Permalink
added startWith
Browse files Browse the repository at this point in the history
  • Loading branch information
manthanank committed Oct 3, 2023
1 parent 4519b01 commit b8572c8
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2983,10 +2983,36 @@ export class App implements OnInit {
bootstrapApplication(App);
```

**startWith** -
**startWith** - Returns an observable that, at the moment of subscription, will synchronously emit all values provided to this operator, then subscribe to the source and mirror all of its emissions to subscribers.

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

@Component({
selector: 'my-app',
standalone: true,
imports: [CommonModule],
template: `
<h1>startWith Example</h1>
`,
})
export class App implements OnInit {

ngOnInit() {
timer(1000)
.pipe(
map(() => 'timer emit'),
startWith('timer start')
)
.subscribe(x => console.log(x));
}
}

bootstrapApplication(App);
```

**withLatestFrom** -
Expand Down

0 comments on commit b8572c8

Please sign in to comment.