[
https://issues.apache.org/jira/browse/SHINDIG-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087243#comment-13087243
]
[email protected] commented on SHINDIG-1578:
--------------------------------------------------------
bq. On 2011-08-16 17:24:01, Henry Saputra wrote:
bq. >
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js,
line 47
bq. > <https://reviews.apache.org/r/1525/diff/1/?file=32902#file32902line47>
bq. >
bq. > Why does the definition registerOnLoadHandler here?
bq.
bq. Dan Dumont wrote:
bq. It is redefined to immediately execute any onload callbacks.
bq.
bq. The sequence of events is:
bq. 1) Gadget starts loading and registers some onload.
bq. 2) Gadget fires an async operation that takes an unknown amount of time
bq. 3) Open Social api is ready and runOnLoadHandlers is called.
bq. 4) Gadget's async operation is done. To be safe it uses
registerOnLoadHandler to make sure everything is all set (in case the async
operation beat the runOnLoadHandlers call)
bq.
bq. At this point, before the change, the call to registerOnLoadHandler
would never result in the callback being executed.
bq. This change makes it so once runOnLoadHandlers is called,
registerOnLoadHandler executes the callback immediately.
bq.
bq. Henry Saputra wrote:
bq. In step 2, the async operation is called outside of the function
registered with registerOnLoadHandler?
bq.
bq. So in step 4, why would the gadget's async handler call
registerOnLoadHandler?
bq.
bq. Dan Dumont wrote:
bq. This is important with some of the changes in dojo 1.7 where the
bootstrap may be very small and included in the gadget page but asynchronously
load more code in. When the application is ready, it should be able to rely on
registerOnLoadHandler to provide them a means of executing gadget code safely.
bq.
bq. Really, the gadget should be able to do any non-gadget-api async
operations while the page is loading. To sync everything back up, the gadget
should be able to rely on registerOnLoadHandler executing their callbacks that
rely on gadget-api operations so that we don't introduce race conditions.
+1 for this change. I think this is pretty much how all of the "ready"
functions I've seen in other JS libraries work (dojo, jquery, ...) -- in any of
those libraries registering code after the trigger has already fired results in
immediate execution, so I think this is probably something people would expect.
- Jesse
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/1525/#review1479
-----------------------------------------------------------
On 2011-08-17 15:18:59, Dan Dumont wrote:
bq.
bq. -----------------------------------------------------------
bq. This is an automatically generated e-mail. To reply, visit:
bq. https://reviews.apache.org/r/1525/
bq. -----------------------------------------------------------
bq.
bq. (Updated 2011-08-17 15:18:59)
bq.
bq.
bq. Review request for shindig.
bq.
bq.
bq. Summary
bq. -------
bq.
bq. If gadgets.util.registerOnLoadHandler was called after the runOnLoad
counterpart was called, the callback would sit in the array... forever alone.
bq.
bq.
bq. This addresses bug SHINDIG-1578.
bq. https://issues.apache.org/jira/browse/SHINDIG-1578
bq.
bq.
bq. Diffs
bq. -----
bq.
bq.
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js
1157211
bq.
bq. Diff: https://reviews.apache.org/r/1525/diff
bq.
bq.
bq. Testing
bq. -------
bq.
bq.
bq. Thanks,
bq.
bq. Dan
bq.
bq.
> Improve gadgets.util.registerOnLoadHandler to be reliable for slow or lazy
> loading gadgets
> ------------------------------------------------------------------------------------------
>
> Key: SHINDIG-1578
> URL: https://issues.apache.org/jira/browse/SHINDIG-1578
> Project: Shindig
> Issue Type: Improvement
> Components: Javascript
> Reporter: Dan Dumont
> Priority: Minor
>
> The sequence of events is:
> 1) Gadget starts loading and registers some onload.
> 2) Gadget fires an async operation that takes an unknown amount of time
> 3) Open Social api is ready and runOnLoadHandlers is called.
> 4) Gadget's async operation is done. To be safe it uses
> registerOnLoadHandler to make sure everything is all set (in case the async
> operation beat the runOnLoadHandlers call)
> At this point, the call to registerOnLoadHandler would never result in the
> callback being executed.
> This should be changed to make it so once runOnLoadHandlers is called,
> registerOnLoadHandler executes the callback immediately.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira