Skip to content
Commit 60af8e85 authored by Dominic Farolino's avatar Dominic Farolino Committed by Chromium LUCI CQ
Browse files

DOM: Implement the `flatMap()` Observable operator

This CL implements the `flatMap()` Observable operator. See
https://wicg.github.io/observable/#dom-observable-flatmap

.

To accomplish this, we introduce a class hierarchy that looks like:

```
// The delegate that the Observable returned from flatMap() uses to
// create subscriptions.
class OperatorFlatMapSubscribeDelegate : Observable::SubscribeDelegate {

  // One of these is created for each subscription created via the
  // delegate above. For example:
  //
  // const mapped = source.flatMap(...);
  // const a = mapped.subscribe(...);
  // const b = mapped.subscribe(...);
  //
  // A `SourceInternalObserver` gets created for each of `a` and `b`.
  class SourceInternalObserver : ObservableInternalObserver {

    // For each value that the source Observable emits, we derive a new
    // "inner" Observable from it and subscribe to it for the rest of
    // its lifetime. This class below is the internal Observer for each
    // of these.
    class InnerFlatMapObserver : ObservableInternalObserver {

    };
  };
};
```

For WPTs:
Co-authored-by: default avatar <ben@benlesh.com>

Bug: 40282760
Change-Id: I281ed693908f4b7c3a6d5f1ce8a70f4c5187018b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5381640


Reviewed-by: default avatarMason Freed <masonf@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1279959}
parent 787cec19
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment