# Load Data only when needed

**URL:** <https://forums.fusetools.com/t/load-data-only-when-needed/5247>\
**Category:** How-to Discussions\
**Created:** [January 10, 2016, 10:26pm UTC](https://forums.fusetools.com/t/load-data-only-when-needed/5247 "2016-01-10T22:26:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.s.alwin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/chris.s.alwin/32/51_2.png) [@chris.s.alwin](https://forums.fusetools.com/u/chris.s.alwin)\
**Post date:** [January 10, 2016, 10:26pm UTC](https://forums.fusetools.com/t/load-data-only-when-needed/5247/1 "2016-01-10T22:26:18Z")

</div>

Appologies if this has been asked before.

I am in the final stages of building an social media style application for internal use. I am a web developer so have been using ionic with it’s MVC style and templating options as thats what im most used.

I feel that fuse has so much to offer and understand that it is still in beta. Is there a way to have the app fetch data from an API only when that page view is loaded? I feel that loading it all at once will just be too much for any mobile device to handle. I have looked at the examples and none really show how to go between views. i have also seen the MVC git hub posted here a while ago and not sure if that fits what im after.

Also is there a way to have page templates to show lists of posts and then single posts for example?

Many thanks.

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [January 11, 2016, 2:32pm UTC](https://forums.fusetools.com/t/load-data-only-when-needed/5247/2 "2016-01-11T14:32:51Z")

</div>

Hi!

You could for example use the `WhileActive` trigger with the `Callback` action in order to fire of some data fetching when your page becomes active.

I’m not sure how familiar you are with [navigation](https://www.fusetools.com/learn/fuse#navigation) in Fuse, but here is what it could look like using a `PageControl`.

```auto
<JavaScript>
    function fetchDataForPage1(){
       ...
    }
    function fetchDataForPage2(){
       ...
    }

    module.exports = {
        fetchDataForPage1: fetchDataForPage1,
        fetchDataForPage2: fetchDataForPage2
    };
</JavaScript>
<PageControl>
    <Page ux:Name="page1">
        ... content of page 1 ...
        <WhileActive>
            <Callback Handler="{fetchDataForPage1}" />
        </WhileActive>
    </Page>
    <Page ux:Name="page2">
        ... content of page 2 ...
        <WhileActive>
            <Callback Handler="{fetchDataForPage2}" />
        </WhileActive>
    </Page>
</PageControl>

```

I hope this helps

---

<div class="post-metadata">

**Author:** ![chris.s.alwin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/chris.s.alwin/32/51_2.png) [@chris.s.alwin](https://forums.fusetools.com/u/chris.s.alwin)\
**Post date:** [January 12, 2016, 9:06pm UTC](https://forums.fusetools.com/t/load-data-only-when-needed/5247/3 "2016-01-12T21:06:47Z")

</div>

Thanks that helps alot.

---

<div class="post-metadata">

**Author:** ![Javier\_Camacho](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@Javier\_Camacho](https://forums.fusetools.com/u/Javier_Camacho)\
**Post date:** [August 24, 2016, 9:07pm UTC](https://forums.fusetools.com/t/load-data-only-when-needed/5247/4 "2016-08-24T21:07:07Z")

</div>

I’ve try to do this using Navigation and it won’t work at all.

function pp() {  
// for(i=1;i\<42;i++){  
// wDay[i] = {“wd”:i};  
// }  
wDay = 25;  
console.log(“BOOM”);  
}  
module.exports = {  
calitms:calitms,  
obsWDay:obsWDay,  
pp:pp  
};
