ObservableEventTarget
This is a sample implementation of ObservableEventTarget
as outlined in the Observable spec.
Step one is to make this example work:
const displayImage = document; const image = ;const load = image;imagesrc = "./possibleImage"; load
Interface as defined by the spec:
interface Event { /* https://dom.spec.whatwg.org/#event */ }
dictionary OnOptions {
// listen for an "error" event on the EventTarget,
// and send it to each Observer's error method
boolean receiveError = false;
// member indicates that the callback will not cancel
// the event by invoking preventDefault().
boolean passive = false;,
// handler function which can optionally execute stateful
// actions on the event before the event is dispatched to
// Observers (ex. event.preventDefault()).
EventHandler handler = null;
// member indicates that the Observable will complete after
// one event is dispatched.
boolean once = false;
}
interface ObservableEventTarget extends EventTarget {
Observable<Event> on(DOMString type, optional (OnOptions or boolean) options);
}
This implementation obviously draws heavily from the example implementation but was re-implemented from scratch as a learning exercise.