-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elm Example #1041
Elm Example #1041
Conversation
@passy++ :) |
I'm excited for this! Please let me know if you run into anything, I'd like to update the elm-todomvc repo as well if anything is missing. |
} | ||
|
||
type Task = | ||
{ description : String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most other apps uses title
for the todo text. Might be good to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
|
||
onEnter : Input.Handle a -> a -> Attribute | ||
onEnter handle value = | ||
on "keydown" (when (\k -> k.keyCode == 13) getKeyboardEvent) handle (always value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a constant for 13
to make it more readable. per spec.
Things that needs fixing:
|
Thanks, Sindre. Addressed some of the issues, here are the remaining test failures:
|
@evancz I think the fix for removing Todos when the text was removed requires a bit of an update to the actions structure. Could you give me a pointer on how that should be done? |
fb43982
to
18d4f47
Compare
So this is the case in which you edit a task such that it has no content, correct? When you press enter while editing, you trigger UpdateTask id desc ->
let update task =
if | task.id /= id -> Just task
| String.isEmpty (String.trim desc) -> Nothing
| otherwise -> Just { task | description <- desc }
in
{ state | tasks <- filterMap update state.tasks } |
Ah, here's one that'll work better: UpdateTask id rawDescription ->
let desc = String.trim rawDescription
update task =
if | task.id /= id -> Just task
| String.isEmpty desc -> Nothing
| otherwise -> Just { task | description <- desc }
in
{ state | tasks <- filterMap update state.tasks } I forgot to do some trimming. My one concern with the modifications so far is the proliferation of |
@evancz Thanks for the input. I made those changes but didn't realize before that any input would immediately be reflected in the actual task. The issue now is that you can't add any whitespace characters before we immediately trim them. Also, whenever you delete the last character of the task, it directly disappears. I think there needs to be some intermediate state, because we also need to add the functionality to undo your changes when you hit escape. |
I don't know if my message got lost or what, but here is the gist of it. I didn't realize that either, I'll edit the elm-todomvc code to fix this issue and then ping here! |
@evancz Awesome! |
I coded up a branch the other day that adds the desired functionality in a pleasant way, but it started running into a bizarre issue on my machine. I am at a conference this week, but I'll do my best to hunt down whatever bug I ran into and ping again. |
Thanks for the update, Evan. And have fun at the conference! On Thu, Oct 23, 2014, 19:37 Evan Czaplicki notifications@github.com wrote:
|
@evancz Hey, just wanted to ping you to see if you had a chance to chase down this bug you encountered. |
Just for the rest, Evan is working on an updated version for the Elm 0.14 release. I'll have another look at tests and so on once that has landed: |
6e81873
to
49d34ed
Compare
I updated this to match the latest state in @evancz's trim branch. I'm seeing a bit of flakiness in the test suite. I'm not sure if this is because of batched rendering or something else. @evancz Something I hadn't thought about before is that now with the learn bar popping in from the side, the center calculation is a bit off for the first "frame" rendered (on large screens at least) and only after interacting with the app in some way it snaps into the right position. Do you have an idea how to mitigate that effect? |
I just updated the code for 0.14.1 which allows The flakiness may be due to how |
@passy I'd love to see this get merged...anything I can do to help? Is the "snapping into position after interaction" the only remaining issue? |
@rtfeldman Thanks for the offer! I'm going to try to bring @evancz's changes back into this branch. If the snapping issue should still be there, I'll give you a shout. :) |
@passy Appreciate you working on bringing the 0.14.1 changes back in. Do let me know if/when you need help testing. |
@addyosmani Just in time! I pushed a rebased, updated version just a second ago. Will run the test suite against it now, but it looks pretty awesome to me. |
Test suite is still flaky, but I think it's fine. Tested the failures manually and all of them were okay. But looking at the stack traces it's pretty obvious that we expect synchronous behavior whereby Elm batches operations with the next vsync. We should certainly not punish using the correct approach here. :) |
Hah! Indeed we shouldn't. Trying this out shortly. Nice work :) |
Manually testing the elm branch, I wasn't able to find anything out of place. Tests are (as you mention) still flaking out. Is it worth adding a note about the test failures if we believe the failures are due to our own synchrony expectations? |
@addyosmani Yup, going to add them to the blacklist. There are a few which unfortunately don't pass. This one is for a good reason, though. :) |
Merged away. Please feel free to add the entry to the blacklist whenever suits :) |
Awesome! Thanks so much for making this happen @passy! 😺 |
@rtfeldman I just juggled some commits around, all the hard work was done by @evancz. 😃 |
Just wanted to chime in and say thanks to @passy as well, I'm super excited to see Elm on the site! :) |
Early stage, keep your fingers away from that merge button!
I tried bringing the elm-todomvc a bit closer to our spec and would like us to consider including it as official example.
Before I go on with that, I'd like to get @evancz's okay for this, though. :)
Eating our own dogfood here:
Why Elm?
A functional reactive language for interactive applications. I'm personally really excited about this, because it doesn't just incrementally tries to improve things, but actually rethink the entire platform from the ground up. This enables some things that are pretty much unheard of in the vanilla JS world, like a time-travelling debugger and a highly interactive development workflow with hot code swapping.
The project has been around for a while and is still super active. There are a couple of TodoMVC implementations floating around, but this one is especially interesting because it brings the virtual DOM ideas to Elm. Here's a nice article describing this in depth: http://elm-lang.org/blog/Blazing-Fast-Html.elm
Outstanding Issues
The layout is a bit buggered right now, I'm not quite sure why. I need to read a bit about Elm's full screen rendering mode. I also haven't run the test suite yet. I'm sure there'll be a couple of edge-cases that haven't been covered yet.