Front end of the Slack clone application.

distinctUntilChanged.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. var distinctUntilChanged_1 = require('../operators/distinctUntilChanged');
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from the previous item.
  6. *
  7. * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted.
  8. *
  9. * If a comparator function is not provided, an equality check is used by default.
  10. *
  11. * @example <caption>A simple example with numbers</caption>
  12. * Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4)
  13. * .distinctUntilChanged()
  14. * .subscribe(x => console.log(x)); // 1, 2, 1, 2, 3, 4
  15. *
  16. * @example <caption>An example using a compare function</caption>
  17. * interface Person {
  18. * age: number,
  19. * name: string
  20. * }
  21. *
  22. * Observable.of<Person>(
  23. * { age: 4, name: 'Foo'},
  24. * { age: 7, name: 'Bar'},
  25. * { age: 5, name: 'Foo'})
  26. * { age: 6, name: 'Foo'})
  27. * .distinctUntilChanged((p: Person, q: Person) => p.name === q.name)
  28. * .subscribe(x => console.log(x));
  29. *
  30. * // displays:
  31. * // { age: 4, name: 'Foo' }
  32. * // { age: 7, name: 'Bar' }
  33. * // { age: 5, name: 'Foo' }
  34. *
  35. * @see {@link distinct}
  36. * @see {@link distinctUntilKeyChanged}
  37. *
  38. * @param {function} [compare] Optional comparison function called to test if an item is distinct from the previous item in the source.
  39. * @return {Observable} An Observable that emits items from the source Observable with distinct values.
  40. * @method distinctUntilChanged
  41. * @owner Observable
  42. */
  43. function distinctUntilChanged(compare, keySelector) {
  44. return distinctUntilChanged_1.distinctUntilChanged(compare, keySelector)(this);
  45. }
  46. exports.distinctUntilChanged = distinctUntilChanged;
  47. //# sourceMappingURL=distinctUntilChanged.js.map