Forum Archive

Passing Data to a View

Dog2puppy

I'm displaying a view by navigating to it with a NavigationController. This view will be dynamic and will display a players stats using data retrieved from a Web API. How can I pass this data to the view?

mikael

@Dog2puppy, create a custom view and load the data when you initialize it:

class MyView(ui.View):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        # load data from API
        # set up subviews based on the loaded data

If you want to set up the view and have it be responsive while you load the data, do the loading in a method decorated with ui.in_background.

nazimaa

Im actually leaning towards the custom $data array. I wont pull in the whole Order table, just make multiple small queries though scopes, I think I would prefer the database to do the heavy lifting.
Sarkari Result Pnr Status 192.168.1.1