Coder Social home page Coder Social logo

elm-socketio's Introduction

#Socket.io for Elm

This library provides Elm code with realtime two-way communication with a server using socket.io. It works quite well for the most common use case, a stable connection to a server.

That said, error handling is limited to setting options up front and reading the connection status. Joining rooms, an inherently impure action, is not supported. If you need to dynamically connect and disconnect, use JavaScript.

For documentation, see src/SocketIO.elm. Supports Elm 0.15 and Socket.io 1.3.5. Also supports vanilla websockets (use the empty string as the event name).

Examples

For each example, a working Elm client and Node server are provided. In separate terminals, run node examples/<example>/server.js and elm reactor, then open your browser as you normally would with the reactor.

Numbers

In the example, client and server exchange a number, incrementing it each time. The server sees odd numbers and the client sees even numbers.

This example is big enough to show all the useful features of the library, but no bigger.

Chat

The main example: a realtime chat program. You can test it out yourself with multiple browser tabs.

Chat is divided into five modules. Protocol most of the knowledge shared with the server and a few other common functions. Login is the login page, Post is the text field and submit button, and View makes the messages look pretty. Finally, ChatClient pulls it all together and does the I/O.

Connected

A very simple example to show that you can obtain a signal about the connection state and use this to render information in the UI.

Websocket

A very simple demonstration of socket.io as cross-browser websocket.

elm-socketio's People

Contributors

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