[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread Erik Lott
No, our pages make their own HTTP requests from within the page, and do not delegate the top layer to make requests. The majority of our api requests are done from within pages, and I think that's likely the case for most apps. Each of our "pages" manage their own http errors through the use of

[elm-discuss] Re: Json.Decode list of objects without known fields

2016-09-16 Thread Oliver Searle-Barnes
You can do this with a Dict but it's a little fiddly because you need to use an ADT to represent the different types of the values import Html import Json.Decode as JD import Dict import String json : String json = """ [{"a": 1, "foo": "bar", "bar": "baz"}, {"a": 2, "foo": "baz", "bar":

[elm-discuss] problem on composition and communication of modules

2016-09-16 Thread Matteo
Hello everybody, I have a problem and I can't find a solution. The code consist in 3 modules. *Main*, *ItemList* and *Form* The *Main* is the glue and message broker of the app. The other two are a list and a form to update the list. The list has it's logic to fetch the results from an api,

[elm-discuss] Re: Json.Decode list of objects without known fields

2016-09-16 Thread Gary Young
In short. Solve this: module Main exposing (..) import Html -- import Json.Decode exposing (Decoder, decodeString, keyValuePairs) json : String json = """[{a: 1, foo: "bar", bar: "baz"}, {a: 2, foo: "baz", bar: "foo"}, {a: 34, foo: "big", bar: "lebowski"}]""" gen_keys : String ->

[elm-discuss] Json.Decode list of objects without known fields

2016-09-16 Thread Gary Young
I love Elm and I strongly believe that it's the future, but I can't solve this one use-case that's stopping me from using it. I have a list of JSON objects like this: [{a: 1, foo: "bar", bar: "baz"}, {a: 2, foo: "baz", bar: "foo"}, {a: 34, foo: "big", bar: "lebowski"}] At runtime the

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 6:07:42 PM UTC+1, Erik Lott wrote: > > Rupert, here is a high level overview of how we currently structure our > elm SPAs: > >1. Top layer: This layer manages routing, page changes, and page >resource loading, and current user state >2. Page layer:

Re: [elm-discuss] Getting started with the serial port (in Electron)

2016-09-16 Thread Duane Johnson
Ian, FYI new members to this mailing list have to have their first message approved by a moderator due to an excess of unsavory spam. I saw that you send 3 or 4 similar messages. I approved the first one and removed the others. You should be able to post future messages without a moderation step

Re: [elm-discuss] Json Decode Issue

2016-09-16 Thread Janis Voigtländer
Your type "Players" is recursive in a way you almost certainly did not intend. That's what leads to this mismatch. > Am 16.09.2016 um 04:09 schrieb Mohammad Samman : > > I have the following elm code: > > import Json.Decode as Json exposing(..) > import Result > > type

[elm-discuss] Json Decode Issue

2016-09-16 Thread Mohammad Samman
I have the following elm code: import Json.Decode as Json exposing(..) import Result type Players = Players (List Players) type alias Player = { name: String , team: Maybe Team } type alias Team = { name: String , players: Maybe Players } teamDecoder: Json.Decoder Team teamDecoder =

[elm-discuss] Getting started with the serial port (in Electron)

2016-09-16 Thread Ian
Hi. I'm looking to build a custom serial port terminal program. It'll receive a binary format that needs to be made human readable (and plotted). It would be awesome if I could write my app in Electron, using Elm. Besides giving me a framework (so I can avoid React and Angular), it seems Elm

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 4:00:39 PM UTC+1, Rupert Smith wrote: > > > I just need to think about how to add functions to query the auth state on > this module too, as it would also be nice to be able to query that all over > the place too. Something like > So to solve this problem I came

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 2:49:25 PM UTC+1, Rupert Smith wrote: > > I think I am going to try the solution from the "Inter-Component > Communication in 0.17" thread. Which is to create pairs of messaging ports. > The module I came with is below. I can import it anywhere and make use of

Re: [elm-discuss] Can you have a port that takes no args? What is its type?

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 3:17:25 PM UTC+1, Joey Eremondi wrote: > > If you need this, make it take an arg of type (), which is just a > placeholder (0 element tuple to be precise, carries no data). > > port logout : () -> Cmd msg > Aha. Thanks. > > On Fri, Sep 16, 2016 at 7:13 AM,

Re: [elm-discuss] Can you have a port that takes no args? What is its type?

2016-09-16 Thread Joey Eremondi
If you need this, make it take an arg of type (), which is just a placeholder (0 element tuple to be precise, carries no data). port logout : () -> Cmd msg On Fri, Sep 16, 2016 at 7:13 AM, 'Rupert Smith' via Elm Discuss < elm-discuss@googlegroups.com> wrote: > port logout : Cmd msg > > yields:

[elm-discuss] Can you have a port that takes no args? What is its type?

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
port logout : Cmd msg yields: 13| port logout : Cmd msg ^ You are saying it should be: Platform.Cmd.Cmd msg But you need to use the particular format described here: Use --force to continue. But

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 11:45:44 AM UTC+1, Rupert Smith wrote: > > > On Friday, September 16, 2016 at 10:13:01 AM UTC+1, Rupert Smith wrote: >> >> On Friday, September 16, 2016 at 1:32:06 AM UTC+1, art yerkes wrote: >>> >>> If your login page can send a message to a parent frame, you can

[elm-discuss] Re: Best [ractices for listening to EventSource (Server-Sent Events)

2016-09-16 Thread Maxwell Gurewitz
You can use the elm websockets library, or ports. On Wednesday, September 14, 2016 at 3:16:10 AM UTC-7, Erwan Queffélec wrote: > > Hi, > > I'm trying to find the cleanest possible way of subscribing and receiving > server side events (SSE) ( >

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 10:13:01 AM UTC+1, Rupert Smith wrote: > > On Friday, September 16, 2016 at 1:32:06 AM UTC+1, art yerkes wrote: >> >> If your login page can send a message to a parent frame, you can use >> Dom.LowLevel.onWindow to receive it in elm. This appeared in 0.17 and is

Re: [elm-discuss] Best [ractices for listening to EventSource (Server-Sent Events)

2016-09-16 Thread Erwan Queffélec
Thanks for your answers. I finally implemented SSE using ports. Works like a charm and was actually quite trivial to code. I would still love to see this implemented directly into an elm package/core package, I'll follow Joaquin's advice and make the proposal to elm-dev On Wed, Sep 14, 2016 at

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 16, 2016 at 1:32:06 AM UTC+1, art yerkes wrote: > > HttpError has BadResponse Int String which you can use to detect non-200 > results to http requests. The way to do it in elm is to write a function > that wraps the creation of login enabled http requests and translates