elm-desktop-app

1.0.0 • Public • Published

Build Status Latest Elm package version Latest CLI version

elm-desktop-app is the simplest way to write desktop applications in Elm. It's built on top of Electron, and it currently supports the following uses:

  • Your app can persist state to disk as a JSON file
  • Build and package Mac, Linux, and Windows apps
  • (soon) prepare and publish an npm package that can launch your app from the command line

Usage

Use the elm-desktop-app command line tool to create a new project, which includes a dependency on the avh4/elm-desktop-app Elm pacakge and a working starting-point for you app:

npm install -g elm-desktop-app
 
mkdir my-app
cd my-app
elm-desktop-app init

Edit the generated src/Main.elm to implement your app and define how to persist data (you can see the full example code here):

import DesktopApp
import DesktopApp.JsonMapping as JsonMapping
 
main : DesktopApp.Program Model Msg
main =
    DesktopApp.program
        { init = ( init, Cmd.none )
        , update = \msg model -> ( update msg model, Cmd.none )
        , subscriptions = \model -> Sub.none
        , view = view
        , persistence = Just persistence
        }
        
type alias Model =
    { name : String
    , count : Int
    }
    
...
    
persistence : JsonMapping.ObjectMapping Model Msg
persistence =
    JsonMapping.object Loaded
        |> JsonMapping.with "name" .name JsonMapping.string
        |> JsonMapping.with "count" .count JsonMapping.int

Use the command line tool to run your app:

elm-desktop-app run

Screenshot of the running example app

The user data for your app is automatically persisted! 💾🎉

You can easily build Mac, Linux, and Windows packages (packages are built to ./elm-stuff/elm-desktop-app/app/dist/):

elm-desktop-app package

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    4

Package Sidebar

Install

npm i elm-desktop-app

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

46.9 kB

Total Files

14

Last publish

Collaborators

  • avh4