“… is something that can act as both an observable and as an observer. And that something is called a Subject.” - page 67
Perhaps this is explained further along in the book however, as far as I have noticed, in the first eleven chapters it is not explained how or why a person would use a subject as an observer. Subjects are used extensively in these chapters as observables but not as observers. Does a discussion of this come up later in the book?
Hi @evs718, it means that a subject can be subscribed to, i.e., to respond to events such as new elements being emitted in a next event, and it can also receive new events such as a next event with an element, which it then emits to its subscribers. This facilitates having an observable that can receive and emit new events during runtime, vs. creating a finite observable.
Showing two examples of adding a next event onto the subject…
// 1 - passing an Event<String> to the on(_:) operator
// 2 - using the shorthand syntax, which does the same thing (although technically adds one more cpu cycle)