I'm using components to change between one or another view. That's what I was recommended to do.
Now every time I change between views the data is being loaded again. Here's a reproduction of the issue. (Check the console).
It is not such a big deal in the example I provided but when calling an external API it is a big deal.
How can I avoid that?
And as a related problem, at the moment it is calling the API (or loading the data in my example) twice on load. Once for each registered component. That shouldn't be like that either.
Should I be using jQuery / Javascript to call the API with ajax and then once I have the data set it in the viewmodel?
$.getJSON("/some/url", function(data) {
viewModel.setData(data);
})