CHAPTER 1 OF 3
A reading has one place to go.
A weather station publishes a temperature. One display needs it, so the station calls that display directly.
Publish 18 °C and watch the display receive it.
Appearance
OBSERVER / THE WALKTHROUGH
See why subscriptions help when the audience keeps changing.
CHAPTER 1 OF 3
A weather station publishes a temperature. One display needs it, so the station calls that display directly.
Publish 18 °C and watch the display receive it.
LIVE LOCAL EXAMPLE
One publish, one direct call.
No reading yet
0 received
No reading published yet.
Publish a reading to see the calls.
These calls run synchronously. The list records real callback deliveries.
The station tells its one display about the reading. This is easy to follow while the audience is fixed.
export class SingleDisplayStation {
private display: WeatherObserver;
constructor(display: WeatherObserver) {
this.display = display;
}
publish(temperature: number): void {
this.display.update(createReading(temperature));
}
}This is the publisher used by the live example. Callback instrumentation records each actual delivery.
Each chapter starts a fresh example. Theme and language keep your place within a chapter.