Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Passing arguments in Electron ipcRenderer/ipcMain  #76

@dough654

Description

@dough654

I apologize if the solution to my issue is simple, as I'm still learning Fable (and F# actually).

I'm trying to use the Electron ipcRenderer and ipcMain for inter/process communication (like I normally would in regular electron development). In my renderer I have something like this:

electron.ipcRenderer.send("Hello", ["World"])

Then in my Main.fs, I set up a listener:

electron.ipcMain.on("Hello", unbox(fun x -> printfn "Hello %A" x)) |> ignore

And when I execute, I get the text Hello [object Object] (which I recognize very well from Javascript development.)

The type signature of of the 'send' function is (channel: string *, args: obj []) -> unit

So if i'm reading that correctly, the send function requires a string to representing the channel name, and arguments which is a list of Objects?

So my question is, how can I enforce a type when sending arguments through ipcRenderer send and receive that same type in my callback function in ipcMain?

Also, is there any documentation for these import APIs? I was not able to find any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions