This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
A small library to get data from a JSONP API, using Elm.
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2017-06-24 22:21:45 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

README

elm-jsonp

A small library that allows you to get data from a JSONP endpoint.

Description

The Jsonp module exposes a script function to define <script> tags, two "padding" functions and a Jsonp event handler.

Scope

This was not meant for production use. The reason I made this is because when I started playing with Elm, I wanted to get data from a JSONP endpoint and I couldn't find an Elm package to quickly help me with that.

Usage

An example of how to use this, taken from the module's docs:

    type Msg
        = Response Value


    update : Msg -> Model -> (Model, Cmd Msg)
    update msg model =
        case msg of
            Response value ->
                case (Json.Decode.decodeValue responseDecoder value) of
                    Ok data ->

                    Err msg ->


    view : Model -> Html Msg
    view model =
        div []
            [ script [ onJsonp Response ] [ text padding ]
            , script [ type_ "application/javascript", src "http://www.example.com/api/resource?callback=parseResponse" ] []
            ]

Padding functions

There is basically one default padding function and a small variation of that, which instead of just requesting the resource, it polls it. Their JavaScript code can be viewed in the module. You can always provide your own. As far as Elm cares it's just a String.