8

This question of mine currently has a score of -1. It has been answered and helpfully commented on, so I don't need any more input on the subject at hand. Instead, I just want to know how I can improve the question, if indeed it needs improving.

I have read the tooltip on the downvote button ("This question does not show any research effort; it is unclear or not useful") and the thread "When is it justifiable to downvote a question?" and still have no idea how they apply to my question.

Keep in mind:

  1. I wrote the minimal example myself. It was not copied and pasted from somewhere.
  2. The jQuery tag is not mine. It was added by someone else. I had no say in the matter.
  3. I was not asking for a jQuery solution, as should be clear from my bothering to write the entire example in vanilla javascript. Since some people like suggest library-dependent solutions, however, I said "feel free" with regard to jQuery just to make them feel welcome, as I'm using it anyway. So far, no one has taken up the invitation, which is fine (better, in fact).
4
  • 2
    Yeah; a single downvote isn't enough to fret about. To me it seems like your question was clear enough anyway, and you could say the downvote was due to the most recent equinox having an impact on one's mouse.
    – Makoto
    Commented Sep 24, 2016 at 21:54
  • 5
    @Makoto I'm not exactly fretting. If I get even more downvotes as a result of this, it will be delightful as a social experiment. But, of course, if there's something really wrong with my question, I'd like to know.
    – bongbang
    Commented Sep 24, 2016 at 22:03
  • 12
    I think you could have started off saying what you were trying to achieve. It's not instantly clear whether the code you've provided has issues, or whether you're asking about whether the goal is reasonable. It's sort of clear, but only after a little while.
    – Jon Skeet
    Commented Sep 25, 2016 at 7:35
  • 6
    I had no say in the matter. Yes you did--you explicitly mentioned in your post, "PS I'm using jQuery, so please feel free to suggest it as a solution." Normally, if you are going to accept jQuery answers, the way to indicate is via a tag. The tag does not mean the answer must use jQuery; it means it could. Conversely, the absence of a jQuery tag is reasonably interpreted by many to mean that jQuery answers are not welcome, regardless of some verbiage buried in the text of the question. So the jQuery tag is consistent with your expectations, IMO. Anyway, rolled back now.
    – user663031
    Commented Sep 26, 2016 at 18:29

3 Answers 3

9

Note: This answer pertains to the question as it stood before being edited.

Since you asked, and please don't take this negatively, as it stands your post boils down to "look at this code I wrote".

The first of the two questions you posed, which I initially interpreted as meaning you wanted thoughts on the user experience, I now see is basically a request for a code review. The second "question" is at heart a statement about a defect in the code design, and an implicit request for someone to fix it. This second question is formulated as what is essentially a tautology: if I want to wait until two processes are finished, do I need to wait for one of them to finish first?.

It's too bad because actually this question contains the seeds of two interesting problems. The first is, how do I handle a long-running task, with the implied question of how do I do this in a non-blocking way? The second is, how do I wait for two processes to both finish before going ahead and doing something else? But these underlying questions were quite well hidden.

They both have useful, interesting answers (although both are relatively well-covered already on SO and elsewhere). The answer to the first is web workers. The answer to the second is something like Promise.all.

Instead, because the questions were not well-formulated, one responder answered with an awkward patch on top of your code, involving a bunch of boolean flags which were set over here and checked over there. Aside from not solving (or apparently even noticing) the blocking problem, this is not best practices for asynchronous and long-running code in 2016. I found it a bit odd, frankly, that you accepted this answer to "thank" the poster for his "effort", even though you yourself said it was not your preferred solution.

Having said that, it is hardly the case, as people have commented here, that a single downvote (not mine) constitutes being "poorly received".

1
  • 'The second "question" is at heart a statement about a defect in the code design, and a request for someone to fix it.' Not exactly. I wanted to know to know if the scheduled task is going to wait for currently-running task to finish and hence obviate the need to "worry" about the former's dependency. In retrospect, I should have said that. Thank you for your input.
    – bongbang
    Commented Sep 27, 2016 at 18:27
5

If something, I found the question a bit unclear and think you are asking for recommendations or input to your solution.

  1. Is this an advisable thing to do? I welcome "Why do you want to do this?" responses, but please give a reason not to do it and/or suggest an alternative.
  2. If it is, then do I need to worry about newContent not being ready when the replacement is due to take place?

So maybe the down vote was instead of voting to close as "unclear what you're asking" or "primarily opinion based".

1

Your example was pretty spot on in describing your situation, so good job there.

The title gets very close to explaining what is desired. From my point of view, you are asking how to avoid blocking the page while a long running computation is being executed while immediately using the result from the computation. That is also what the title states.

However, the prose of your question does not state that, and that is the improvement you need to make here. (some time passes) I went ahead and made that edit for you as an example since we are discussing it here. Please feel free to make any changes or roll it back if you feel it is not inline with your original intent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .