Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pairs.d.ts 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Observable } from '../Observable';
  2. import { SchedulerAction, SchedulerLike } from '../types';
  3. import { Subscriber } from '../Subscriber';
  4. import { Subscription } from '../Subscription';
  5. /**
  6. * Convert an object into an Observable of `[key, value]` pairs.
  7. *
  8. * <span class="informal">Turn entries of an object into a stream.</span>
  9. *
  10. * <img src="./img/pairs.png" width="100%">
  11. *
  12. * `pairs` takes an arbitrary object and returns an Observable that emits arrays. Each
  13. * emitted array has exactly two elements - the first is a key from the object
  14. * and the second is a value corresponding to that key. Keys are extracted from
  15. * an object via `Object.keys` function, which means that they will be only
  16. * enumerable keys that are present on an object directly - not ones inherited
  17. * via prototype chain.
  18. *
  19. * By default these arrays are emitted synchronously. To change that you can
  20. * pass a {@link SchedulerLike} as a second argument to `pairs`.
  21. *
  22. * @example <caption>Converts a javascript object to an Observable</caption>
  23. * ```javascript
  24. * const obj = {
  25. * foo: 42,
  26. * bar: 56,
  27. * baz: 78
  28. * };
  29. *
  30. * pairs(obj)
  31. * .subscribe(
  32. * value => console.log(value),
  33. * err => {},
  34. * () => console.log('the end!')
  35. * );
  36. *
  37. * // Logs:
  38. * // ["foo": 42],
  39. * // ["bar": 56],
  40. * // ["baz": 78],
  41. * // "the end!"
  42. * ```
  43. *
  44. * @param {Object} obj The object to inspect and turn into an
  45. * Observable sequence.
  46. * @param {Scheduler} [scheduler] An optional IScheduler to schedule
  47. * when resulting Observable will emit values.
  48. * @returns {(Observable<Array<string|T>>)} An observable sequence of
  49. * [key, value] pairs from the object.
  50. */
  51. export declare function pairs<T>(obj: Object, scheduler?: SchedulerLike): Observable<[string, T]>;
  52. /** @internal */
  53. export declare function dispatch<T>(this: SchedulerAction<any>, state: {
  54. keys: string[];
  55. index: number;
  56. subscriber: Subscriber<[string, T]>;
  57. subscription: Subscription;
  58. obj: Object;
  59. }): void;