[webkit-changes] [WebKit/WebKit] 14125a: Implement InternalObserver for Observable

Keith Cirkel noreply at github.com
Wed Jul 24 00:15:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 14125a03f1ad98b91fbe1d65d46c6f15c36e421b
      https://github.com/WebKit/WebKit/commit/14125a03f1ad98b91fbe1d65d46c6f15c36e421b
  Author: Keith Cirkel <webkit at keithcirkel.co.uk>
  Date:   2024-07-24 (Wed, 24 Jul 2024)

  Changed paths:
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/bindings/js/JSSubscriberCustom.cpp
    A Source/WebCore/dom/InternalObserver.cpp
    A Source/WebCore/dom/InternalObserver.h
    A Source/WebCore/dom/InternalObserverFromScript.cpp
    A Source/WebCore/dom/InternalObserverFromScript.h
    M Source/WebCore/dom/Observable.cpp
    M Source/WebCore/dom/Observable.h
    M Source/WebCore/dom/Subscriber.cpp
    M Source/WebCore/dom/Subscriber.h

  Log Message:
  -----------
  Implement InternalObserver for Observable
https://bugs.webkit.org/show_bug.cgi?id=276839

Reviewed by Ryan Reno.

This implements `InternalObserver` for the `Observable` and
`Subscriber` classes, simplifying their functionality by
using a delegate class to manage some of the different types
of Observers. This will make it much easier to implement
operators (e.g. take, map, filter).

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp:
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/dom/InternalObserver.cpp: Copied from Source/WebCore/dom/Observable.h.
(WebCore::InternalObserver::error):
* Source/WebCore/dom/InternalObserver.h: Copied from Source/WebCore/dom/Observable.h.
(WebCore::InternalObserver::complete):
(WebCore::InternalObserver::InternalObserver):
  The point of this class is to act as a base for further operators which will
  require mapping observables by creating intermediary subsribers, each which
  need an Observer. The spec describes these as Internal Observer.
  (https://wicg.github.io/observable/#internal-observer)
* Source/WebCore/dom/InternalObserverFromScript.cpp: Added.
(WebCore::InternalObserverFromScript::create):
(WebCore::InternalObserverFromScript::next):
(WebCore::InternalObserverFromScript::error):
(WebCore::InternalObserverFromScript::complete):
(WebCore::InternalObserverFromScript::visitAdditionalChildren const):
(WebCore::InternalObserverFromScript::InternalObserverFromScript):
  This class allows us to simpify Subscriber so that it only ever takes
  InternalObservers, by taking the existing way Subscriber consumes a
  SubscriptionObserver and mapping that to an InternalObserver delegate instead.
  I called this InternalObserverFromScript as it's InternalObserver that will
  only be created from the Observer#subscribe() IDL calls.
* Source/WebCore/dom/InternalObserverFromScript.h: Copied from Source/WebCore/dom/Observable.h.
* Source/WebCore/dom/Observable.cpp:
(WebCore::Observable::subscribe):
(WebCore::Observable::subscribeInternal):
(WebCore::Observable::Observable):
(WebCore::Observable::makeSubscriber): Deleted.
* Source/WebCore/dom/Observable.h:
* Source/WebCore/dom/Subscriber.cpp:
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
* Source/WebCore/dom/Subscriber.h:

Canonical link: https://commits.webkit.org/281278@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list