Giter Club home page Giter Club logo

fable-elmish's Introduction

Elmish: Elm-like abstractions for F# applications targeting Fable.

npm version Gitter Windows Build status Mono Build Status

Elmish implements core abstractions that can be used to build applications following “model view update” style of architecture, as made famous by Elm. The library however does not model any "view" and is intended for use in conjuction with a DOM/renderer, like React/ReactNative or VirtualDOM. For those familiar with Redux, the Fable applications targeting React or ReactNative may find Elmish a more natural fit than Redux allowing one to stay completely in idiomatic F#.

Elmish abstractions have been carefully designed to resemble Elm's "look and feel" and anyone familiar with post-Signal Elm terminology will find themselves right at home.

Concepts

Elm architecture operates using following concepts, as they translate to Elmish:

Model

This is a snapshot of your applications state, defined as an immutable data structure.

Message

This an event representing a change (delta) in state of your applications, defined as a discriminated union.

Init

This is a pure function that produces inital state of your application and, optionally, message(s) to process.

Update

This is a pure function that produces new state of your application given the previous state and, optionally, new message(s) to process.

View

This is a pure function that produces new UI layout/content given the current state, defined as a F# function that uses a renderer (such as React) to declaratively build a UI.

Program

This is an opaque data structure that combines all of the above + your setState function to start a dispatch loop.

Advanced Concepts

A dispatch loop is responsible for running the update cycle.

Commands

Command is an opaque data structure that when evaluated may produce one or more new messages.

Tasks

Task is any code that will execute when a command is evalutated, like reading a database, defined in Elmish as async or promise blocks or just a plain function.

Subscriptions

These are external sources of events to process, defined as a F# functions that can dispatch new messages as they happen.

Parent-child composition

Please refer to Elm's diagrams for an overview.

Application state is composed of the state of all its children, events buble up from the children all the way to the top update function where they are distributed back to the children in an explicit fashion. The views delegate portions of the model to the appropriate child views to produce the new UI.

Extras

Elmish-React: boilerplate to get the React/Native root components registered and start the dispatch loop.

npm install --save-dev fable-elmish-react

For more information see the readme

Elmish-Snabbdom: boilerplate to get the Snabbdom virtual DOM registered and start the dispatch loop.

npm install --save-dev fable-elmish-snabbdom

For more information see the readme

Elmish-Debugger: RemoteDev tools integration adds support for time-travelling debugger and import/export.

npm install --save-dev fable-elmish-debugger

For more information see the readme

Building Elmish

Make sure you have yarn installed (yarn is to npm like paket is to nuget) and it's in the PATH.

npm install -g yarn

Then run fake:

./build.sh or build

And/or build samples:

build Samples

fable-elmish's People

Contributors

2scomplement avatar alfonsogarciacaro avatar banashek avatar davidpodhola avatar davidtme avatar dsyme avatar inchingforward avatar maxwilsonms avatar ncave 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.