Advertisement
fabiobiondi

Angular RxJS multiple filters - draft

Jun 23rd, 2017
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. emailMatch(input1: HTMLInputElement, input2: HTMLInputElement) {
  2. const input1$ = Observable.fromEvent(input1, 'keyup')
  3. .map((evt: any) => evt.target.value);
  4. const input2$ = Observable.fromEvent(input2, 'keyup')
  5. .map((evt: any) => evt.target.value);
  6.  
  7. return input1$.merge(input2$)
  8. .filter(text => text.length > 3)
  9. .filter(res => {
  10. return input1.value === input2.value;
  11. })
  12. }
  13. }
  14.  
  15.  
  16.  
  17.  
  18. emailMatch(this.emailRef.nativeElement, this.emailRef2.nativeElement)
  19. .subscribe(
  20. res => console.log ('MATCH', res),
  21. err => console.log ('MATCH ERROR', err),
  22. () => console.log ('MATCH DONE'),
  23. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement