View Full Version : processing after vs before event returns
codegoboom
03-03-2005, 08:29 AM
Maybe it would be better to return from an event, and then do the processing, in some cases, but I wonder if that would cause side-effects, in general... anyone know?
joh6nn
03-03-2005, 08:59 AM
not sure i know what you mean. examples?
codegoboom
03-03-2005, 09:38 AM
I'm not sure either... ;)
I was messing around with a scheme to use query strings on anchors, and ended up having to re-call the click event from the function (to prevent unloading the document)... so basically, I've got a choice whether to do the processing on the first or second pass.
If I choose the second pass, then processing would occur after the anchor was visited (after the event, so to speak), and if a lengthy loop was involved, then processing that on the first pass would delay navigation (like a regular event), so maybe the delay would be good to avoid... or not?
joh6nn
03-03-2005, 07:42 PM
i always try to dissocciate processing from what's going on now as much as i can. example: i'm helping maintain an open source media player. right now, it loads the entire playlist before it starts playing. what that means is that if you have a giant playlist, you wait a long time between starting the program and actually hearing music. what i'm going to try and do is see if i can't get it to start playing as soon as there's at least one song in the queue, on the idea that by the time the first song is done playing, the rest of the playlist will be loaded, or at the very least, there will be at least one more song in fully loaded in the queue, affording still more time to finish loading the playlist.
so from that perspective, i'd say your second-pass method would be a better choice, because it would show the user that something's going on more immediately, instead of having them sit there and wait a second or two for the JS to finish iterating its loop. ie, they see that clicking on the link has started to load a new page, and they have to wait for the page to load, but they don't click on the link 4 or 5 times, because every time they do, they have to wait a second or two before they can see that clicking had any effect.
here's hoping that i both understood, and offered some sort of insight
codegoboom
03-04-2005, 04:57 AM
Yeah, I was sort of wondering if that was likely to have unusual drawbacks, which I hadn't considered... thanks for the insight.
joh6nn
03-04-2005, 10:15 AM
well, the sort of draw backs that it might present really depend on the situation. it's hard to say for sure whether that kind of of dissocation is actually a good idea, without seeing the code/site in question. it's also not necessarily a question that i can answer for you; you may end needing to poll your users to see what they'd prefer.
codegoboom
03-04-2005, 10:27 AM
You're right, I was just throwing the idea out there--on the off chance that someone had experienced a general problem with that sort of thing... ;)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.