Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 1x 1x 3x 3x 6x 5x 10x 1x 3x 3x 3x 6x 4x 1x 2x 2x 2x 2x 4x 4x 4x 1x | "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DifferentClockClient = exports.ObservedClockClient = exports.ObservedClock = void 0; class ObservedClock { constructor() { this.time = 0; this.observers = []; } reset() { this.time = 0; } tick() { this.time++; this.notifyAll(); } addObserver(obs) { this.observers.push(obs); } notifyAll() { this.observers.forEach(obs => obs.notify(this.time)); } } exports.ObservedClock = ObservedClock; class ObservedClockClient { constructor(theclock) { this.theclock = theclock; this.time = 0; theclock.addObserver(this); } notify(t) { this.time = t; } getTime() { return this.time; } } exports.ObservedClockClient = ObservedClockClient; // the Observer gets to decide what to do with the notification class DifferentClockClient { constructor(theclock) { this.theclock = theclock; this.time = 0; this.notifications = []; // just for fun theclock.addObserver(this); } notify(t) { this.notifications.push(t); this.time = t * 2; } getTime() { return (this.time / 2); } } exports.DifferentClockClient = DifferentClockClient; //# sourceMappingURL=clockWithObserver.js.map |