View Full Version : createCallback?
cluettr
27 Jul 2007, 7:05 PM
Here is a code snippet. Instead of performing a defer I'd rather use what I think is called a callback. In my mind a callback is what is performed after a function completes. In the below I'd rather just wait until loading the datastore is complete until I move to creating my grid... because they seem to be running over one another...techinically the defer is just buying me 20 miliseconds of time.
setupDefaultDataSource();
var constructDetailsGrid = function() {
buildGrid();
};
constructDetailsGrid.defer(20);
jsakalos
28 Jul 2007, 3:39 AM
Here is a code snippet. Instead of performing a defer I'd rather use what I think is called a callback. In my mind a callback is what is performed after a function completes. In the below I'd rather just wait until loading the datastore is complete until I move to creating my grid... because they seem to be running over one another...techinically the defer is just buying me 20 miliseconds of time.
setupDefaultDataSource();
var constructDetailsGrid = function() {
buildGrid();
};
constructDetailsGrid.defer(20);
If you want to "wait until ds is loaded" then listen to the store's load event and setup your grid from your load event handler.
cluettr
28 Jul 2007, 10:03 AM
You are 100% correct. Just did a small test of that and it works perfect. I'm going to re-write my code.
franklt69
28 Jul 2007, 5:52 PM
when could be useful to use createCallback?
regards
Frank
jsakalos
28 Jul 2007, 6:17 PM
when could be useful to use createCallback?
regards
Frank
I could be useful I you need to pass somewhere reference to your function but you need it to be called with your arguments. Scope of such created callback is global.
createCallback could be considered as a simpler version of createDelegate if you neglect the difference in passing arguments: createCallback takes direct arguments, createDelegate arguments array.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.