Giter Site home page Giter Site logo

laurentpayot / fsharp-fable-elmish-example Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 270 KB

F# Fable Elmish example, with Preact and Vite.

License: MIT License

F# 75.77% JavaScript 21.11% HTML 2.47% CSS 0.65%
elm elm-architecture elm-lang elmish elmish-applications fable fsharp functional-programming mvu preact vite

fsharp-fable-elmish-example's Introduction

F# Fable Elmish example

The goal of this example is to show how to get typical Elm features (see below) in F#. It uses Fable to transpile F# to JavaScript and Elmish to get The Elm Architecture (TEA), also known as the Model View Update (MVU) pattern.

Elmish normally uses React under the hood, but in this example React was seamlessly replaced by Preact to get performances similar to Elm, both in term of speed and bundle size.

Featuring

  • Startup flags
  • Getting a random number
  • Routing
  • Subscription via a JavaScript custom event
  • Foreign Function Interface (FFI) using synchronous and asynchronous functions imported from JavaScript
  • JSON decoding
  • Keyed list
  • Unit tests
  • Hot Module Replacement (HMR)
  • Debugger (via Redux DevTools)

Prerequisites

To run this example app on your local machine, you will need:

Usage

  • pnpm i to install Node.js dependencies as well as F# dependencies.
  • pnpm start to start the Vite development server with automatic refresh on http://localhost:5000.
  • pnpm build to build the bundle, then pnpm serve to serve it as a single page application on http://localhost:5000.
  • pnpm test to run unit tests.
  • pnpm test:watch to run unit tests in watch mode.

If you get an error like ENOSPC: System limit for number of file watchers reached, run pnpm watchers-fix to increase the number of watchers on your system. If you want this increase to be permanent, see this answer on StackOverflow.

License

MIT

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.