fable-f#

How to extend a JS class in fable

爷,独闯天下 提交于 2021-01-27 16:10:23
问题 Given a class defined in an external JS library (let's call it Foo) then I'd like to extend in F# type bar() = inherits Foo ... However I can' only find examples of how to integrate with functions and [<Import("Foo", from="my-module")>] let Foo = JsNative will of course not let me derive Bar from Foo. So how Do I do that 回答1: The Import attribute can be used on a type declaration. e.g. [<Import("Foo", from="my-module")>] type Foo() = class end type Bar() = inherit Foo() You can then also

How to extend a JS class in fable

橙三吉。 提交于 2021-01-27 15:40:25
问题 Given a class defined in an external JS library (let's call it Foo) then I'd like to extend in F# type bar() = inherits Foo ... However I can' only find examples of how to integrate with functions and [<Import("Foo", from="my-module")>] let Foo = JsNative will of course not let me derive Bar from Foo. So how Do I do that 回答1: The Import attribute can be used on a type declaration. e.g. [<Import("Foo", from="my-module")>] type Foo() = class end type Bar() = inherit Foo() You can then also

Attributes vs Properties in Fable Elmish

心已入冬 提交于 2020-05-17 05:56:28
问题 I am going through the book "Elm in Action" and trying to convert the application developed there to Fable-Elmish. Many things translate directly from Elm to Elmish but not everything (at least not directly). Right now I am trying to understand how to set properties on custom HTML element in Fable-Elmish. The book has an example of a JS Range object with the following script in the HTML file: <link rel="stylesheet" href="http://elm-in-action.com/range-slider.css"> <script src="http://elm-in

Fable F# > js compile multiple .fsx files

戏子无情 提交于 2019-12-22 06:09:37
问题 How can I compile multiple .fsx files using Fable? I (naively) tried to just pass an array of them in the fable.config file like this: { "outDir": "app", "projFile":["app/index.fsx", "app/testmod.fsx"], "sourceMaps": true, "targets": { "production": { "sourceMaps": false } } } but get the warning: ARG ERROR: TypeError: Path must be a string. Received [ 'app/index.fsx', 'app/testmod.fsx' ] I know I could make a full-blown .fsproj file and point the fable compiler to that but it seems like

Fable, invoke F# from JS

…衆ロ難τιáo~ 提交于 2019-12-11 22:03:31
问题 I see a lot of documentation on F# JS interop and how to use JS code from F#, but I am trying to do the opposite: Call some of my F# code from (inlined) JS. I cannot find any information regarding this. Is it possible? If so how? 回答1: So after 2 weeks of trying everything I could think about, google every word combination I could think of and creating a SO account to ask for help: I finally found how to do this. It turns out I needed to add this to my webpack config's output section: