david-mark-llc / jessie

Javascript cross-browser library builder enabling (real) progressive enhancement
http://jessie.herokuapp.com
39 stars 13 forks source link

Add the ability to create defered renditions #243

Open adamsilver opened 11 years ago

adamsilver commented 11 years ago

"Basically, anything that will inject elements during testing should wait until "ready". Need to have a new meta flag that indicates deferred feature testing. Then the builder can wrap those in a deferUntilReady call. This function will likely be the first (and one of very few) to use that mechanism, though it won't affect much today (e.g. off-track mobile devices, very old Opera versions). The deferred functions can't be detected during the parse; have to wait for "ready" callback."

adamsilver commented 11 years ago

Currently deferUntilReady takes a single function. The idea behind it to my knowledge, is so that you only have a single "ready" function but it can just loop through a bunch of functions and call them. E.g.

var readyFunctionsToCall = [];

function addToReadyQueue(fn) { readyFunctionsToCall.push(fn); }

deferUntilReady(function() { for(var i = 0; i < readyFunctionsToCall.length; i++) { readyFunctionsToCall [ i ] (); } });

If Jessie uses it internally then the calling application cannot use deferUntilReady. Need to have a quick discussion with DM.

web-bert commented 11 years ago

Should we provide a jessie.ready() so users can pass in a function to call when all the deferred's have been executed?

adamsilver commented 11 years ago

We already do jessie.deferUntilReady(); which takes a single function. Like the one in my previous comment. The issue is I want to use the same deferUntilReady function for internal feature testing.

On Tue, Oct 15, 2013 at 9:01 AM, web-bert notifications@github.com wrote:

Should we provide a jessie.ready() so users can pass in a function to call when all the deferred's have been executed?

— Reply to this email directly or view it on GitHubhttps://github.com/rassie/jessie/issues/243#issuecomment-26315722 .

web-bert commented 11 years ago

I think that is the point: you can't use the same function for internal testing or external use. Plus the jessie.ready() will have to call the callback immediately if all the deferred's have been run.

adamsilver commented 11 years ago

My concern is that deferUntilReady has been designed like this for a reason. If we had another function just for internal we would just be duplicating the stuff required by the calling app.

david-mark commented 10 years ago

Can use same one for internal feature testing. See how My Library does the same.

It's just another dependency.