News for hackers. Stuff that matters.
Re:Fable: F# to JavaScript compiler by kristiandupont on Monday October 30, 2017 @05:10AM (#15583791)
Sure, but I would still like to see how I would use this in the context of a browser. How do I interact with existing JS libraries? How would I use it with React or something else? How would I even call window.alert()?
Re:Fable: F# to JavaScript compiler by piaste on Monday October 30, 2017 @06:56AM (#15584146)
For React, install the appropriate library[1] and then call the functions you need from the Fable.Helpers.React.* namespace. If you want to see a complete implementation of Fable + React in action, the canonical example is https://github.com/SAFE-Stack/SAFE-BookStore

For alert(), you'll find it in Fable.Import.Browser.window.alert()

(In case you're wondering, the Fable convention is that the Fable.Import.* namespace is used for pure JS bindings with no business code, while libraries with an actual translation layer are placed in the Fable.Helpers.* namespace.)

[1] https://www.nuget.org/packages/Fable.React/