Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

2 functions calling each others, how to declare them ?

Hello,
I have a pretty simple problem :

I have 2 functions :

function displayItems(itemList){
 --------some code here------
    feedTableView.addEventListener('scrollEnd',function(e)
    {
           loadRSSFeed(url)

    });

---------some other code here-------
}

function loadRSSFeed(url){
 --------some code here------
        // Now add the items to a tableView
        displayItems(itemList);
---------some other code here-------
}

and of course I get the warning : loadRSSFeed was used before it was defined..

So is there a way to just declare the functions first before writing their content code ?

Regards

Armindo

— asked December 7th 2010 by Armindo Da Silva
  • declare
  • function
  • recursive
1 Comment
  • what is the event listener inside that function? Does it really need to be?

    — commented December 7th 2010 by Aaron Saunders

2 Answers

  • Accepted Answer

    >So is there a way to just declare the functions first before writing their content code ?

    You can just declare one (or both) using var to eliminate the warning:

    var loadRSSFeed;
    function displayItems() { ... };
    function loadRSSFeed() { ... };
    

    It doesn't matter if loadRSSFeed ends up being a function, object, or data type.

    — answered December 7th 2010 by Doug Handy
    permalink
    0 Comments
  • Great ! thanks Doug.

    — answered December 8th 2010 by Armindo Da Silva
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.