question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to implement constraints for reducers, etc.

See original GitHub issue

Maybe it’s just my newness to the Elm Architecture, but I’m having a hard time figuring out how to do constraints with reducers, etc. For example, in the GoMix todo example when you click the button, it adds a todo whether the input has a value or not. For keyup I can put a constraint like this:

// If the input has value and the user hits Enter, add todo.
onkeyup={e => (e.keyCode === 13 && e.target.value) ? actions.add() : ""}

But for the button click that won’t work because it doesn’t have access to the input value. Old school way would be on button click check value of input, if it has a value, do stuff, otherwise not. How do you do that with this pattern? This would also come up with form validation. 🤔

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rbiggscommented, Feb 21, 2017

Yeah, I was thinking an effect was the way to go, but I wan’t sure. Thanx. 🍺🍻

0reactions
tunnckoCorecommented, Feb 21, 2017

@dodekeract 👍

@rbiggs it sounds to me like an effect too. Make an effect, then just pass e to it, and do you checking and all that stuff there, not in the view part.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux Fundamentals, Part 3: State, Actions, and Reducers
The official Redux Fundamentals tutorial: learn how reducers update state in response to actions.
Read more >
Understanding Redux: A tutorial with examples
In this tutorial, we'll show you what Redux is, why you should use it, and how it works. We'll demo using a simple...
Read more >
Reducer Composition with Effects in JavaScript #1528 - GitHub
We'd be able to use vanilla combineReducers() , or really, ... So basically, with the set of constraints imposed by the way Redux...
Read more >
Optimization of Two-Stage Cylindrical Gear Reducer with ...
revising the corresponding boundary constraints dynamically during the optimization process are researched and implemented. Finally, dedicated interactive.
Read more >
[PDF] Reliability-based design optimization for RV reducer ...
stable transmission and high positioning accuracy, and etc. ... implement RBDO for the RV reducer, an RBDO optimi-. zation model for the RV ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found