Wikipedia defines reactive programming as follows:
"A programming paradigm oriented around data flows and the propagation of change."
The very first thought of this may imply some similarities to a well-known event-driven programming. The data flows and the propagation of change sound a bit like something we may implement via the \SplSubject
, \SplObjectStorage
, and \SplObserver
interfaces in PHP, as per the following trivial example. The \SplObjectStorage
interface further encapsulates the \Countable
, \Iterator
, \Traversable
, \Serializable
, and \ArrayAccess
interfaces:
<?php class UserRegister implements \SplSubject { protected $user; protected $observers; public function __construct($user) { $this->user = $user; $this->observers = new \SplObjectStorage(); } public function attach(\SplObserver $observer) { $this->observers->attach($observer); } public function detach(\SplObserver...