# Scalable Component Abstractions

* Read Date - 2020-02-16
* Fixed `SubjectObserver` example,

```scala
abstract class SubjectObserver {
  type S <: Subject
  type O <: Observer

  abstract class Subject {
    self : S =>

    private var observers: List[O] = List()

    def subscribe(obs: O): Unit = observers = obs :: observers

    def publish(): Unit =
      for (obs <- observers) obs.notify(self)
  }

  abstract class Observer {
    def notify(sub: S): Unit
  }
}

object SensorReader extends SubjectObserver {
  type S = Sensor
  type O = Display

  abstract class Sensor extends Subject {
    val label: String
    var value: Double = 0.0

    def changeValue(v: Double): Unit = {
      value = v
      publish()
    }
  }

  class Display extends Observer {
    override def notify(sub: Sensor): Unit =
      println(s"${sub.label} has value ${sub.value}")
  }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.dewaka.com/papers/cs/scalable-component-abstractions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
