Pre-load data

54 views
Skip to first unread message

Jan Eriksson

unread,
Jun 5, 2015, 10:36:09 AM6/5/15
to widok-f...@googlegroups.com
When using a RoutingApplication, is there any way to pre-load data and pass it to the page that is to be rendered? Something like angular resolve. I know we don't have dependency injection :)

How would you go about to solve it with our current router? I'm thinking:

1. load data in some onClick event (while showing the ajax spinner)
2. store it in my RoutingApplication object
3. manually trigger the route change
4. read data from application


Is there some other way of doing it?



Yay! First forum post! :-)

Tim Nieradzik

unread,
Jun 7, 2015, 9:58:58 AM6/7/15
to widok-f...@googlegroups.com
Hi Jan,

You can leverage the fact that you can execute arbitrary code in your RoutingApplication object as part of its initialisation. I'd suggest to pre-load the data in a Future and then access its reference in the pages where needed.


Best,
Tim

Jan Eriksson

unread,
Jun 9, 2015, 7:31:59 AM6/9/15
to widok-f...@googlegroups.com
What I was primarily aiming for was to avoid rendering/displaying the page before the data is available (to avoid dom flickering). I'm also not interested in pre-fetching all data, but only data depending on route-parameters (#/books/12 for example). While data is being fetched i want to remain on the page and display some ajax loader and have the route change kick in when the data is available - so that the page can be rendered at once.

I just had some ideas about how this could be implemented in the current router, something similar could work with your new "redesigned router" as well. I will make a github issue of that.
Reply all
Reply to author
Forward
0 new messages