This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return this.http.get<Something>("https://api.some.com/things/1").pipe( | |
| map(this.extractSomeProperty), | |
| catchError(this.handleError) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { expect } from "chai"; | |
| import { fakeSchedulers } from "rxjs-marbles/mocha"; | |
| import { timer } from "rxjs"; | |
| import * as sinon from "sinon"; | |
| describe("timer", () => { | |
| let clock: sinon.SinonFakeTimers; | |
| beforeEach(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { componentFromStream, createEventHandler } from "recompose"; | |
| import { from } from "rxjs"; | |
| import { debounceTime, distinctUntilChanged, map, startWith } from "rxjs/operators"; | |
| export const SomeComponent = () => { | |
| const { handler, stream } = createEventHandler(); | |
| const SearchingComponent = componentFromStream(props => from(stream).pipe( | |
| map(event => event.target.value), | |
| debounceTime(400), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { mount } from "enzyme"; | |
| import * as React from "react"; | |
| import { fakeSchedulers } from "rxjs-marbles/jest"; | |
| import { SomeComponent } from "./SomeComponent"; | |
| describe("SomeComponent", () => { | |
| beforeEach(() => jest.useFakeTimers()); | |
| it("should indicate when searching", fakeSchedulers(advance => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, Input, OnInit, OnDestroy } from "@angular/core"; | |
| import { debounceTime, distinctUntilChanged, switchMapTo, takeUntil } from "rxjs/operators"; | |
| import { observe } from "rxjs-observe"; | |
| @Component({ | |
| selector: "some-component", | |
| template: "<span>Some useless component that writes to the console</span>" | |
| }) | |
| class SomeComponent implements OnInit, OnDestroy { | |
| @Input() public name: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { observe } from "rxjs-observe"; | |
| const instance = { name: "Alice" }; | |
| const { observables, proxy } = observe(instance); | |
| observables.name.subscribe(value => console.log(name)); | |
| proxy.name = "Bob"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should indicate when searching', fakeSchedulers(() => { | |
| const fixture = TestBed.createComponent(SomeComponent); | |
| fixture.detectChanges(); | |
| const compiled = fixture.debugElement.nativeElement; | |
| const input = compiled.querySelector('input'); | |
| expect(compiled.querySelector('.searching')).toBeNull(); | |
| fixture.componentInstance.form.patchValue({ term: 'foo' }); | |
| fixture.detectChanges(); | |
| expect(compiled.querySelector('.searching')).toBeNull(); | |
| tick(400); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { TestBed, async } from '@angular/core/testing'; | |
| import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | |
| import { fakeSchedulers } from 'rxjs-marbles/jasmine/angular'; | |
| import { SomeComponent } from './some.component'; | |
| describe("SomeComponent", () => { | |
| beforeEach(async(() => { | |
| TestBed.configureTestingModule({ | |
| declarations: [SomeComponent], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { FormBuilder, FormGroup } from '@angular/forms'; | |
| import { Observable } from 'rxjs'; | |
| import { debounceTime, distinctUntilChanged, pluck } from 'rxjs/operators'; | |
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <form [formGroup]="form"> | |
| <input formControlName="term" type="text"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { combineLatest, Observable } from "rxjs"; | |
| import { takeUntil } from "rxjs/operators"; | |
| declare const a: Observable<number>; | |
| declare const b: Observable<number>; | |
| declare const notifier: Observable<any>; | |
| const c = a.pipe( | |
| o => combineLatest(o, b), | |
| takeUntil(notifier) |