Just building off of the earlier answer from Maxime Mangel, I've took the hacky approach, but adapated it a little bit to make use of local storage. I'm sharing this is an alternative for anyone else that needs to find a way to pass in Args to a Fable-Elmish App that are set/collected prior to the start.
In the App.fs (last file run/compiled):
let initialArgs = {
Sender = Browser.Dom.window.localStorage.getItem("Sender")
HubConnectionURI = Browser.Dom.window.localStorage.getItem("ServiceURI")}
let startApplication args =
Program.mkSimple init update view
|> Program.withReactSynchronous "elmish-app"
|> Program.withSubscription Subscription.hubConnection
|> Program.withConsoleTrace
|> Program.runWith args
do startApplication initialArgs
This pulls from the Local Storage Values set in Browser prior to the App Initialization, so then you can have these set in the JS however, you'd like.
within index.html:
<body>
<div id="elmish-app" class="elmish-app"></div>
<script>
window.localStorage.setItem('Sender', 'Chairman Meow')
window.localStorage.setItem('ServiceURI', 'http://localhost:7071')
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/3.1.3/signalr.min.js"></script>
<script src="bundle.js"></script>
</body>
You could of-course adapt this however you wanted to pull in the values/variables that are set in local storage. I needed these 'dynamic' initial arguments for parameterizing a Subscription that I want to start on the Program Run and am using this for a demo I'm working on for using SignalR in Fable-Elmish, and I will likely adapt this to prompt for these on loading the page.
However, the point here is that you can do whatever you want to get the values, as long as they're set in the Local Storage prior to the start of the App! I find this a relatively 'cleaner hack', but am still a beginner with Fable-Elmish, and there is likely a better approach.
[Just want to highlight for further clarity that these will be a part of the Initial Model]