top | item 36276934

(no title)

dhucerbin | 2 years ago

But React doesn’t prohibit calling Intl API in your code.

discuss

order

mejutoco|2 years ago

Elm does have a escape hatch: ports. You could use ports to call any javascript library. I have done it and it works.

Ports are needed because they make any js code go through the same "even router" than any Elm code. It works very well. Without ports js would break the guarantees that Elm provides. It is quite an elegant solution.

The only problem is if you wanted to call something requiring very high performance, like an event loop in a game, then going through a port call on every frame would probably be too slow. Even in that case you could write a bigger chunk outside of elm and call it from elm, and it would be ok. Please note that this problem happens with any?/most? FFI implementations in any language.

P.S. React does not prohibit anything. They just shame you into it not being best practices :)