Giter Site home page Giter Site logo

fable-electron's Introduction

Fable.Electron

Fable bindings for Electron.

Contributions are welcome!

Electron releases frequently, and I can make no promises to keep the bindings updated in a timely manner. Pull requests are more than welcome, whether it’s bindings for new APIs, new helpers, bugfixes, or just improving typos and formatting in the documentation. If you want to create a PR with non-trivial changes, consider opening an issue first so you don’t waste time and effort on something that might not be accepted or might already be underway.

If you want to take over maintenance of Fable.Electron, let me know!

How to use the bindings

Note that since Fable.Electron is mostly just bindings, the official Electron docs is the place to go for general Electron usage.

For an example app with complete boilerplate for Electron apps using Fable and Elmish with hot module reloading, time-travel debugging, etc., check out Fable-Elmish-Electron-Material-UI demo.

To get started with the bindings, simply:

  • Install the Fable.Electron Nuget package as well as the electron npm package. Make sure the electron version is compatible with the bindings. Fable.Electron supports Femto.
  • open Electron. In addition to all the the type definitions, you now have access to two entry points for the Electron API:
    • main for everything that can be used from the main process
    • renderer for everything that can be used from the renderer process

You can also use electron to access everything, but consider using only main or renderer.

By convention, class constructors are accessible as static Create members. For example, to instantiate a BrowserWindow, you call main.BrowserWindow.Create().

Helpers

In addition to the bindings, Fable.Electron also gives you access to some convenience helpers if you open Electron.Helpers:

Accelerators (keyboard shortcuts)

Accelerators in Electron are simply strings with a specific format. If you want, you can use createAccelerator with the Modifier and Key helper types to create them in a strongly typed manner:

// Returns an accelerator string that can be used to register shortcuts
createAccelerator: Modifier list -> Key -> string

Example:

let accelerator = createAccelerator [Modifier.Ctrl; Modifier.Alt] Key.Tilde
main.globalShortcut.register(accelerator, fun () -> (* do stuff *))

// The above is identical to:
main.globalShortcut.register("Ctrl+Alt+~", fun () -> (* do stuff *))

If you need to use a key that is not in the Key type but that you know works, you can use a string with Fable's !! operator, or just skip the helper altogether (also, please make a PR to add the key!):

let accelerator = createAccelerator [Modifier.Ctrl] !!"="

// The above is identical to:
let accelerator = "Ctrl+="

Deployment checklist

  1. Make necessary changes to the code
  2. Update the changelog
  3. Update the version and release notes in the package info, as well as the supported Electron versions in the NpmPackage node
  4. Commit and tag the commit (this is what triggers deployment from AppVeyor). For consistency, the tag should be identical to the package version number.
  5. Push the changes and the tag to the repo. If AppVeyor build succeeds, the package is automatically published to NuGet.

fable-electron's People

Contributors

alfonsogarciacaro avatar cmeeren avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.