toshi0383 / TVMLKitchen

Swifty TVML template manager with or without client-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tab Reloading

anthonycastelli opened this issue · comments

It's me again! Another feature request if it doesn't already exist haha.

Is there currently a way to reload a view in a tab? What Im after is either being able to tell a tab to reload its data or when the tab is loaded each time fetch the data it needs. Does something like this exist that I can use? If not what would be the best route to implement something like this?

The way the tabs work is it creates a document per tab. If the document exists then we don't load it again.

https://github.com/toshi0383/TVMLKitchen/blob/swift2.2/Sources/kitchen.js#L50-L58

We could possibly add a new method like: Kitchen.reload() which would use navigationDocument.replaceDocument method to reload that current view.

That would work. Currently if data changes on an API there is no way or refreshing anything.

commented

I would love to have this feature, I'm trying to figure out a work around right now to fix this. Because if a user updates something within their Defaults there is no way of viewing that back. I can take a look at this and submit a PR if you would like. I am just not sure where to begin with this, haven't messed with the JS api much. So some guidance would be nice on how you guys would like it done. the navigationDocument.replaceDocument is the right idea but from what I'm messing with currently it will not work for what we need it to do. It basically needs to call Kitchen.serve again.

Update
Just mocking up an idea based on what you guys have, something like this could work where we just pass an extra argument to serve and pass it to the JS like this

function menuBarItemPresenter(xml, reload) {
    reload = reload === undefined ? false : true;

    var feature = currentTab.parentNode.getFeature("MenuBarDocument");
    if (feature) {
        var currentDoc = feature.getDocument(currentTab);
        if (!currentDoc || reload) {
            feature.setDocument(xml, currentTab);
        }
    }
}

This idea causes some hitching animations from what I can tell.

Just submitted a prototype in #90.
What do you guys think ?

Merged.
As you can see in the sample code here, reloading the tab before selected solves "hitching animation" issue.
It still seems to be a workaround, but it works fine this way I guess.
Let us know any further feature requests or bug reports !

commented

Awesome!
Let me know when that is published!

Released ! 🚢