Coder Social home page Coder Social logo

signals.elm's Introduction

Signals!

Build Status

This is a toy project to learn Elm. It renders some German railway signals as SVG, because I wanted to learn them as well.

Setup

To be written ๐Ÿ˜ฑ

Usage in your own project

The project is still being developed, so it can't yet be used from JavaScript directly. But you can use the signals from Elm.

Initialize a any kind of signal, call one of the initializers:

SignalModel.distantSignal : SignalModel.Model
SignalModel.signalRepeater : SignalModel.Model
SignalModel.combinationSignal : SignalModel.Model
SignalModel.mainSignal : SignalModel.Model

-- distant signal, a repeater, a combination signal and a main signal in a record
signals = { distantSignal = SignalModel.distantSignal
          , signalRepeater = SignalModel.signalRepeater
          , combinationSignal = SignalModel.combinationSignal
          , mainSignal = SignalModel.mainSignal
          }

Any of those signals can be displayed with calling

Signal.view : SignalModel.Model -> SignalModel.SignalType -> Svg msg

-- for example:
Signal.view signals.distantSignal SignalModel.Ks

For setting an aspect of the signal or configure certain things, have a look at the available messages in src/Messages.elm. Because the combination signal has both a distant as well main state, you have to tell the update function, which one you want to update (also for the distant or main signals).

Send the all messages both to the main signal and all corresponding distant signals. This way they will show the correct distant aspect for the main signal.

Signal.update : Messages.Target -> SignalModel.Model -> SignalModel.Model

-- for example:
signals =
    { signals
        | combinationSignal =
            Signal.update
                (ToDistantSignal (SetAspect Proceed))
                signals.combinationSignal
        , mainSignal =
            Signal.update
                (ToMainSignal (SetSpeedLimit (Just 4)))
                signals.mainSignal
    }

signals.elm's People

Contributors

igel avatar

Stargazers

 avatar

Watchers

 avatar  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.