Elm in Action, Chapter 5, requestAnimationFrame isn't working?

Hello All,

I have been working through Elm in Action and I just finished Chapter 5. I am using elm-live src/PhotoGroove.elm --open --start-page=index.html -- --output-elm.js to run the application currently. I have an issue that is supposed to be fixed via the following line of code: https://github.com/chiroptical/elm-in-action/blob/master/chapter5/initialize.js#L7. When you run the application the initial canvas is never drawn (

). I have to click a button or move a slider for images to appear. I tried various things from some other posts, like adding a time-out or another requestAnimationFrame, however that didn’t seem to do anything. I also looked at Richard’s code at https://github.com/rtfeldman/elm-in-action and it doesn’t contain this function. I am a bit unsure about how to solve this. Any help is appreciated!

Thank you,

Barry

1 Like

There is a bug in the code. Change these lines to this:

        GotPhotos (Ok ((first :: _) as photos)) ->
            applyFilters { model | status = Loaded photos first.url }

Basically, the port was never called after the initial loading of the images.

2 Likes

Welp, I feel stupid. I should have added tracing to narrow down the issue instead of immediately posting here. I really appreciate your help!

Nothing stupid about learning. :wink:
Have fun!

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.