Observer pattern makes imperative style

I watched Coursera's Reactive Programming course, which Scala uses to implement the Observer pattern. There, Martin Odersky says that the Observer pattern forces imperative programming, which we see because subscriber handlers are of type Unit.

He says here: https://class.coursera.org/reactive-002/lecture/107 at 9:40

I really do not understand:

1.When should handlers have a type Unit?

2. How is the Observer pattern creating imperative programming?

+4
source share
2 answers

, OP.

- - ; , Unit, , . . , , : (, notifyObservers (observer)) , , . .

, Unit , , , , , , -effects. , , , - , Observer, , , ...

+7

, , Unit, , . , , .

, , , .

wiki , in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes,, state , , FP,

+2

Source: https://habr.com/ru/post/1619922/


All Articles