Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using Redux Devtools directly without remotedev #67

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading