Questions tagged [fable-f#]

A cross compiler from F# to JavaScript

Fable is a cross compiler from F# to JavaScript. The intention is to be able to both code using node modules as well as emitting node modules or web JS while working in F#

157 questions
30
votes
0 answers

How to debug Fable using Visual Studio (not Code)

I know it is possible to debug Fable apps in VS Code and hit breakpoints, but I haven't seen any examples of such when using Visual Studio. How can one debug Fable apps using Visual Studio, being able to hit breakpoints, inspect variables, etc.?
cmeeren
  • 3,890
  • 2
  • 20
  • 50
16
votes
1 answer

When writing F# for Fable, when should I use async and when should I use promise?

F# with Fable provides two computation expressions for working with callback based code: async and promise. async is more idomatic F#, but it is not clear to me how well it will work in the browser. Ideally I would be able to use async everywhere,…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
11
votes
3 answers

Getting file input content with Fable

I've seen simple ways to read contents from a file input in JavaScript using HTML5 File API. This is my view method, inside a small fable-arch app: let view model = div [ attribute "class" "files-form" ] [ form [ …
villasv
  • 6,304
  • 2
  • 44
  • 78
9
votes
1 answer

How can I do a simple elmish router?

Sorry, but I'm a newbie with Fable and F#. I started a boilerplate from SAFE project, and I created a SPA with two pages. However, all the logic is inside a single file. My question is. How can I implement a router putting each view in one file? I…
Pablo Darde
  • 5,844
  • 10
  • 37
  • 55
9
votes
1 answer

Does mkProgram expose more functionality than mkSimple?

I am trying to understand the difference between mkSimple and mkProgram in Fable-Elmish, or Elmish.WPF which I am actually using. (Can someone perhaps produce a tag for elmish.wpf please?) I have found Elmish.WPF to be incredibly effective, I use it…
Bent Tranberg
  • 3,445
  • 26
  • 35
8
votes
2 answers

How to handle redirects to auth provider from the backend in Fable Elmish SPA

I have an AspNetCore backend api (in F# with Giraffe) that uses AzureAD authentication with Microsoft.AspNetCore.Authentication.AzureAD.UI, with stateful session store, and https only cookies. The frontend is an Elmish SPA compiled to js with…
Balinth
  • 548
  • 4
  • 10
8
votes
1 answer

How to write Fable bindings for React component library

Is there any step-by-step guidance available on how to write bindings for a react component library from F#/Fable? The only example I could find is fable-react-toolbox which makes extensive use of the deprecated KeyValueList attribute. I am…
Michael Thomas
  • 1,354
  • 7
  • 18
8
votes
4 answers

Convert React.FormEvent to BodyInit using Fable-Elmish

I am trying to upload a file using Fable-Elmish and the React Helpers. However, I can't work out how to convert the form event when a file is selected into something that I can send off to the server using Fetch. This is the view: R.input [ …
Dan O'Leary
  • 2,660
  • 6
  • 24
  • 50
7
votes
1 answer

Fable/F# - How do I save enums or discriminated unions to the browser?

I can save a string to local browser storage with Browser.localStorage.setItem(key, str) but when I try to stringify a discriminated union (e.g. by calling string on it), it comes out as [Object object]. Since the FSharp.Reflection and…
Overlord Zurg
  • 3,430
  • 2
  • 22
  • 27
6
votes
1 answer

Import css or scss file into Fable/F# React Component?

I'm using Webpack bundler and configured appropriate loaders for .fs, .scss, .css files. Now how do I import a stylesheet into a Fable based React Component? open Fable.React open Fable.React.Props // open 'MyComponent.scss' ???? type…
user10891762
6
votes
1 answer

How can I base64 encode using Fable (F#)?

I use FetchAPI of Fable.PowerPack to make basic authentication application, but I am in trouble because I can not base64 encode. For example, I wrote such a code, let base64enc str =     str     |> Seq.map byte     |> Array.ofSeq     |>…
6
votes
1 answer

How to consume websockets

How do I consume data from, and push data to a websocket using Fable? I found this github issue which suggests that it can be done, but cannot find any documentation or examples of how to achieve this.
Lawrence
  • 3,287
  • 19
  • 32
6
votes
1 answer

Fable F# to Javascript: Parameterless functions being given a parameter when referenced

I am having difficulty referring to parameterless functions in Fable. With this example: let f1 () = 1 let someRefTof1 = f1 I'd expect the generated js to look something like this: function f1() { return 1; } var someRefTof1 = f1; but…
Stewart_R
  • 13,764
  • 11
  • 60
  • 106
5
votes
1 answer

Using third party React Components with Fable/Elmish

I'm trying to integrate Carbon Design System - React SDK in a Fable/Elmish application and it looks like I have to create the property type definitions (some of them I just guessed) for every component in order to use it. The component already has…
A. Matías Quezada
  • 1,886
  • 17
  • 34
5
votes
6 answers

Fable.React - editing an Input field moves cursor to end of text

I'm working with the Elmish.Bridge flavor of the SAFE stack. At the top level of the view, I create an input field like this: Input.input [ Input.Value(model.FieldValue); Input.OnChange(fun e -> dispatch (EditFieldValue(e.Value))) ] When I edit…
Overlord Zurg
  • 3,430
  • 2
  • 22
  • 27
1
2 3
10 11