sapui5 - Lazy loading data after initial load -
in section 10 of openui5 developer guide tutorial on routing (see here), talks lazy loading. tutorial not show how lazy-load data.
scenario: have openui5 app gives list of employees , on detail page shows main employee details , gives access further info, projects, hobbies, , notes selected employee's resume.
because in 99.99% of use cases user not wish @ hobbies, prefer not load hobbie data main model app. make choice based on performance concerns. instead detect user has requested see hobbies , load hobbies data current user model.
how ?
edit: managed discover ontabselect() plumbing [tip other confused folks, openui5 tutorials tend leave stuff out keep on topic - useful @ code of working versions if lost]. after routing in tutorial makes lot more sense.
my question remains relevant changes 'user clicks tab , load further json data model. should in oninit() of target controller or before navto() invoked load controller?' can see issue because of async nature of json fetch meaning if use oninit() end displaying page controls before data arrives.
what best practice please ? money on pre navto() though ugly pattern have repeat json fetch elsewhere if have route lazy-loading view.
to stick example. can attach hobbiescontroller in oninit method display event of target displaying:
var router = this.getownercomponent().getrouter(); var target = router.gettarget("resumetabhobbies"); target.attachdisplay(this.ondisplay, this);
then define ondisplay method called if select corresponding tab , populate model there.
Comments
Post a Comment