Giter Club home page Giter Club logo

elm-node-pubsub's Introduction

Elm+Node Pub/Sub example

Licence: Apache 2.0

EXPERIMENTAL

This is a sample of how to use Cloud Pub/Sub from the pure functional web app language Elm, using the Node Pub/Sub libraries. It's basically just to see if I could, so please do not base your product on this! :)

This is UNOFFICIAL and EXPERIMENTAL, and not recommended at this time. Caveat emptor!

This is part of a Medium blog post: https://feywind.medium.com/using-cloud-pub-sub-on-node-js-from-elm-2a769731c097

What is it?

Elm is a language that was designed for pure functional programming when working with client side web apps. My read of it is that it's derived strongly from Haskell, but it transpiles to a JavaScript app.

One thing led to another, and here is an Elm app that runs on Node and communicates with Pub/Sub in an event-driven way. I am definitely not holding this up as a paragon of Elm excellence (I just started learning it a few days ago), but it's neat that it does something.

Why?

Elm modules are easily shareable across both client and server, because they are guaranteed side-effect free and type safe. The peace of mind that provides would be useful in a server-side tool. You could also e.g. share Elm types across the client and server when building an Elm web app.

Running it

You'll need to use npm install -g to get both elm and elm-node commands. npm install will set up your project, then, and npm run run runs it. You will also need a Pub/Sub emulator running unless you tweak the defaults in src/index.js.

Design thoughts

The optimal place to put the barrier between Elm and JavaScript is a bit wibbly-wobbly, and will probably depend a great deal on what you want to achieve. The one I chose here is basically to let Elm logic receive messages and decide how to respond and ack. It's a really simplistic thing, but maybe it'll be something to help unstick you if you're playing around with Elm.

elm-node-pubsub's People

Contributors

feywind avatar

Watchers

 avatar

elm-node-pubsub's Issues

Thank YOU

Ty so much for your article and this repo! I love Elm but recently wanted to write a CLI app and was bummed Elm isn't a general purpose language. But this is the next best thing ๐Ÿ˜„

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.