DEV Community
Follow
Properly improper FRP: Time as a discrete function of events
The author argues against the strict functional-reactive programming (FRP) principle that everything must be a continuous function of time. They propose "Fiat Time," where time is defined by discrete events in a user interface, such as user interactions or animation completion. This contrasts with continuous time, needed for smooth animations, which is computationally expensive for general UI development. Most UI interactions are event-driven and discrete, making continuous recalculation unnecessary. Using events to define time simplifies state management and testing, especially with libraries like RxJS. Defining time as a sequence of events allows modeling actions consistently regardless of their specific timing. Mature event stream libraries provide operators to reconcile different event sequences. Redefining time as event sequences potentially brings event-driven patterns like Rx Observables under the FRP umbrella. Ultimately, this approach still aligns with FRP because if everything is a function of events, and time is a function of events, everything is still a function of time.