FP 的概念还是了解一些的,今天看到楼主提的 Elm ,真心觉得前端越来越繁荣了,也希望自己也能跟着了解一下。
wiki 上我看到了这样一段话:
The key abstraction in Elm is called a Signal. It is a value that changes over time.[14] For example, the Mouse.position signal in the following code acts on “the current position of the mouse”, so the programmer does not need to manually handle an event each time the mouse moves:[15] Signal.map refers to the map function in the Signal module, which applies show to each mouse position to transform it into a DOM element onscreen.
import Mouse
import Graphics.Element exposing (show, Element)
main : Signal Element
main =
Signal.map show Mouse.position
感觉 Elm 弱化了 Event ,然后还看到了一段话:
Interoperability with HTML, CSS, and JavaScript
Elm uses an abstraction called ports to communicate with JavaScript.[20] It allows values to flow in and out of Elm programs, making it possible to communicate between Elm and JavaScript.
Elm also has a library called elm-html which lets users use HTML within Elm and style it with CSS.[21] It uses a virtual DOM approach to make updates efficient.
这部分感觉就和 React 一样了吧,我喜欢 FP 的理念,就像 Linux 的 Pipe