This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Helper function for use with realm npm package
version 1.0.6
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.6
Committed At 2016-12-12 16:37:30 UTC
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

Modules

README

realm

Realm is an alternate implementation of Redux using Elm. Actions are created in JavaScript with a payload, which is sent through ports into your Elm store. Elm performs the role of a reducer in Redux, and sends the new state back to JavaScript.

Usage

JavaScript

npm install @aardito2/realm

createStore(elmStore, initialState = {}, enhancer)

// using elm-webpack-loader
import elmStore from './store.elm';

const initialState = {};
const store = createStore(elmStore.Store, initialState);

applyMiddleware

See Redux docs.

createAction(actionType) => payload => action

const INCREMENT = 'increment';
const increment = createAction(INCREMENT);

const SET_STRING = 'set_string';
const setString = createAction(SET_STRING);

store.dispatch(action)

dispatch(increment());
dispatch(setString('foo'));

Elm

elm-package install @aardito2/realm

Your Elm file should be a Platform.programWithFlags. In main, your update should use Realm.updateState, which takes an outgoing port and an update function and returns a new update function which will automatically send your updated state back to JavaScript. Your outgoing port will have the signature model -> Cmd msg. This port must be named nextState! For each action used in JavaScript, two things are required:

  1. An incoming port with the same name as the action type.
  2. A subscription to the above port which converts the incoming action into a Msg to be handled by your update function. See store.elm for a full example of the structure of the store in Elm.