Skip to content

Instantly share code, notes, and snippets.

@byrichardpowell
Created September 6, 2012 12:46
Show Gist options
  • Save byrichardpowell/3655898 to your computer and use it in GitHub Desktop.
Save byrichardpowell/3655898 to your computer and use it in GitHub Desktop.
Method Optimisation
// Cycle through these URL's
// We update the models URL using these
// Then we fetch data using it
var nextUrl = function() {
var urls = [
'js/_data/api/tags/index.json%3frange=21-30',
'js/_data/api/tags/index.json%3frange=31-40',
'js/_data/api/tags/index.json%3frange=0-10',
'js/_data/api/tags/index.json%3frange=11-20'
]
var i = 0;
nextUrl = function() {
i++
if ( i === urls.length ) i = 0;
return urls[ i ]
}
return nextUrl();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment