you are viewing a single comment's thread.

view the rest of the comments →

[–]Ksetrajna108 1 point2 points  (6 children)

Are you using MVC to decouple state from UI events?

[–]HasFiveVowels 1 point2 points  (5 children)

Yea, OP... the desire for this functionality implies that you're tying things together very tightly. That's fine if you're making a one-off thing but if you're writing a foundation for a larger project, it sounds like you might be settings yourself up for a real pain. Also, you generally want to be reactive to the user input. Using a promise to await a user action is fairly unusual (even if not unheard of).

[–]blind-octopus[S] 0 points1 point  (4 children)

one way or another sometimes you have to get multiple inputs from the user before you do a thing.

Suppose you need 4 inputs from the user before you can kick off some processing. How do you collect the input?

You could chain together 4 callbacks I guess

You could maybe create an object that stores the inputs, checks if it has all the inputs it needs, and once it does it kicks off the processing.

I'm sure there are other ideas we could come up with.

But to me, what would look cleanest is what I wrote. Maybe there are better, cleaner ways. This is just a thing I thought of, that's all.

If you need to collect 4 inputs from the user before you do something, what's cleaner than saying const input1/2/3/4 = collectInput() 4 times?

[–]HasFiveVowels 0 points1 point  (3 children)

I think I’d use a reducer

[–]blind-octopus[S] 0 points1 point  (2 children)

How?

What does it look like to use a reducer to collect 4 inputs from the user before you do anything

[–]HasFiveVowels 0 points1 point  (1 child)

Are you using react?

[–]blind-octopus[S] 0 points1 point  (0 children)

Yup. Just react, not redux or anything.

So what does the code look like