henrychavez / nativescript-bottom-navigation

Nativescript plugin for Android & iOS to have the bottom navigation bar of Material Design
Apache License 2.0
58 stars 18 forks source link

Load Tabs from promise #63

Closed MichaelSmi closed 5 years ago

MichaelSmi commented 5 years ago

Problem: I need to load the tabs from local sqlite database so the result is only available in promise. Is there any way to make the tabs "wait" for the tabs binding variable to be set?

Which platform(s) does your issue occur on?

What type of device?

Please, provide the following version numbers that your issue occurs with:

Is there any code involved?

I call the following promise function inside the onload event: itemComponent.setNavigationItems(args, "tabs") But when I set the tabs data binding object it is "undefined" because the tabs init function will not wait for the promise :(

BTW: The below code is also much better to prevent overwriting other binding data. This could improve your docs!


page.bindingContext = Object.assign({
            tabs: [
                new BottomNav.BottomNavigationTab("First", "ic_home"),
                new BottomNav.BottomNavigationTab("Second", "ic_view_list"),
                new BottomNav.BottomNavigationTab("Third", "ic_menu"),
            ]
        },
        page.bindingContext);
´´´
henrychavez commented 5 years ago

Hi, I need a better example of what you are trying to do because the component creates the tabs when you set values to the tabs property

as you can see

[tabsProperty.setNative](value: BottomNavigationTab[]) {
    this.createTabs(value);
}

can you show me how you are doing the promise and setting the value for the tabs? because one of the problems can be that you are not using an observable for your bindingContext

henrychavez commented 5 years ago

closed due to inactivity