npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-elm

v3.1.0

Published

The Elm Architecture in Redux

Downloads

34

Readme

redux-elm

NPM version Dependencies devDependency Status Build status Downloads Join the chat at https://gitter.im/salsita/redux-elm

The Elm Architecture in JavaScript for building really scalable applications.

redux-elm is framework specifically tailored for solving difficult problems that people have to face in modern front-end application development, it is heavily based on Composition.

Goal of this project is to solve hard problems by defining patterns, not implementation. Library is very lightweight and you should be able to fully understand the codebase. Main building block is redux which serves as predictable state container and because redux-elm is built on top of that, you will be able to benefit from all of its tooling:

  • DevTools
  • Time Travel
  • Immutable application snapshots
  • Easy unit testing

Because redux-elm is about Patterns, we have really thorough documentation which guides you to utilize all the ideas that redux-elm provides.

See why the Elm Architecture matters.

How does it look?

redux-elm is about Components and every Component must define two pieces Updater and View where Updater is very similar to Redux reducer and View is simple React Component, of course you can use your own View library.

Counter Updater

import { Updater } from 'redux-elm';

const initialModel = 0;

export default new Updater(initialModel)
  .case('Increment', model => model + 1)
  .case('Decrement', model => model - 1)
  .toReducer();

Counter View

import React from 'react';
import { view } from 'redux-elm';

export default view(({ model, dispatch }) => (
  <div>
    <button onClick={() => dispatch({ type: 'Decrement' })}>-</button>
    <div>{model}</div>
    <button onClick={() => dispatch({ type: 'Increment' })}>+</button>
  </div>
));

Installation & Usage

You can install redux-elm via npm.

npm install redux-elm --save

We didn't want to keep all the boilerplate in redux-elm repo therefore we've prepared simple redux-elm-skeleton repositiory which will serve as easiest way to start using redux-elm.

git clone [email protected]:salsita/redux-elm-skeleton.git
cd redux-elm-skeleton
npm install
npm start
open http://localhost:3000

You will see Hello World so that you can immediately open your favorite Text Editor and start writing your own application. Skeleton repo integrates redux-devtools Chrome extension, so we strongly recommend installing the extension.

Boilerplate

Are you looking for more feature complete boilerplate? There are two boilerplates which works well with redux-elm:

  1. https://github.com/jmarceli/redux-elm-boilerplate based on react-boilerplate
  2. https://github.com/salsita/redux-boilerplate from redux-elm authors but soon to be deprecated

Documentation

Goal of documentation is explaining basic principle of redux-elm and this is Composition, it's divided into few chapters to gradually increase amount of complexity.

  1. Getting Started Tutorial
  2. GifViewer Tutorial
  3. Composition

First two chapters describes basic principles, while Composition part is the most important part explaining how redux-elm helps you building really scalable application. There's also Chapter which explains how to properly Unit test your application.

Examples

You will find original Elm Architecture examples written in JavaScript using redux-elm:

  1. Counter
  2. Counters Pair
  3. Dynamic List of Counters
  4. Random GIF Viewer
  5. Random GIF Viewers Pair
  6. Dynamic List of Random GIF Viewers

Static Typing

Definitely one of the most important features of Elm programming language is its type system. Elm is statically typed language and fully supports type inference, unfortunately this is not same for JavaScript, however you can still use flowtype because redux-elm provides type definitions for everything that's publicly exposed. We strongly encourage you to do so, because Flow is a great help for spotting subtle bugs before they actually appear. Using Flow in your redux-elm project is seemless and does not require any additional effort except installing flow as your project's dependency.

Flow checks:

  • correct model shape
  • Matchers
  • and many more...

Discussion

Join the discussion on gitter