Skip to content

Commit

Permalink
Add Redux Devtools without remotedev
Browse files Browse the repository at this point in the history
  • Loading branch information
Linschlager committed Jun 18, 2024
1 parent 7d4aab9 commit 7cc08ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/Fable.Import.RemoteDev.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Fable.Import

open System
open Fable.Core

module RemoteDev =
Expand All @@ -21,8 +20,7 @@ module RemoteDev =
let JumpToAction = "JUMP_TO_ACTION"

type Options<'msg> =
{ remote : bool
port : int
{ port : int
hostname : string
secure : bool
getActionType : ('msg->obj) option }
Expand Down Expand Up @@ -61,7 +59,7 @@ module RemoteDev =
[<Import("connect","remotedev")>]
let connect<'msg> (options: Options<'msg>): Connection = jsNative

[<Import("connectViaExtension","remotedev")>]
[<Emit("window.__REDUX_DEVTOOLS_EXTENSION__.connect($0)")>]
let connectViaExtension<'msg> (options: Options<'msg>): Connection = jsNative

[<Import("extractState","remotedev")>]
Expand Down
19 changes: 10 additions & 9 deletions src/debugger.fs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
namespace Elmish.Debug

open Fable.Import
open Fable.Import.RemoteDev
open Fable.Core.JsInterop
open Fable.Core
open Thoth.Json

[<RequireQualifiedAccess>]
module Debugger =
open FSharp.Reflection

let showError (msgs: obj list) = JS.console.error("[ELMISH DEBUGGER]", List.toArray msgs)
let showWarning (msgs: obj list) = JS.console.warn("[ELMISH DEBUGGER]", List.toArray msgs)

Expand Down Expand Up @@ -37,17 +34,21 @@ module Debugger =
else
makeMsgObj("NOT-AN-F#-UNION", x)

let fallback = { Options.remote = true
hostname = "remotedev.io"
let fallback = { hostname = "remotedev.io"
port = 443
secure = true
getActionType = Some getCase }

match opt with
| ViaExtension -> { fallback with remote = false; hostname = "localhost"; port = 8000; secure = false }
| Remote (address,port) -> { fallback with hostname = address; port = port; secure = false }
| Secure (address,port) -> { fallback with hostname = address; port = port }
|> connectViaExtension
| ViaExtension ->
{ fallback with hostname = "localhost"; port = 8000; secure = false }
|> connectViaExtension
| Remote (address,port) ->
{ fallback with hostname = address; port = port; secure = false }
|> connect
| Secure (address,port) ->
{ fallback with hostname = address; port = port }
|> connect

type Send<'msg,'model> = 'msg*'model -> unit

Expand Down

0 comments on commit 7cc08ff

Please sign in to comment.