-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support menu item reload configuration #15
Comments
Is there a workaround to reload the pages for now? |
@cpwc I think you can manually update page document related to menu item using If you need to reload page when menu item is selected you can use TVML events. It would be something like this: // Usually menu is rendered as first document so we retrieving it from global documents list and adding event listener to be able to update page on menu item select
navigationDocument.documents[0].addEventListener('select', event => {
// Updating page only when `menuItem` is selected and page id is equal to what we are looking for
if (event.target.tagName === 'menuItem' && event.target.id === 'my-target-page-id') {
// Getting rendered page config from attached page document
const menuBar = event.target.parentNode;
const feature = menuBar.getFeature('MenuBarDocument');
const prevPageDocument = feature.getDocument(event.target);
const prevPageConfig = prevPageDocument.page;
// Creating new page instance and updating menu cache
ATV.Menu.setDocument(ATV.Page.create(prevPageConfig), event.target.id);
}
}); I haven't tested it but I hope you get the idea ;) P.S. |
@cpwc You may use the Milestone-Enhancements branch for now until it gets merged to master. I have added this functionality and you will need to add the configuration ...
menu: {
items: [{
...
attributes: {
reloadOnSelect: true
}
}]
}
... @a-ignatov-parc Thanks for your inputs, your solution will also work 👍 Now coming to the two main things that you pointed out, too many 1) On a side note, the whole purpose of this library was to be minimalistic and provide a rock solid architecture to quickly build your TVML applications. I have recently added a demo app with streaming examples https://github.com/emadalam/appletv-demo and also the boilerplate code https://github.com/emadalam/appletv-boilerplate. I think there is a need to add more documentation and sample examples to highlight the many possibilities available with P.S. @a-ignatov-parc I have checked your TVDML library before as well, nice work 👍 People who like that declarative approach, would really like TVDML. |
@emadalam sure, let me try. Dependencies:
That is why Restrictions:
|
Also using string templates restricts how you update rendered documents. You can't use such templates to flush updated state because you will loose user's focus. The only solution is to manually update nodes in |
@a-ignatov-parc thanks for that snippet it works well for my current use case to reload the page. @emadalam I will test out your current branch! Thanks for getting it out! It really helps a lot when contents under menu page requires updating. 👍 Edit: Works great! |
@a-ignatov-parc Thanks for the inputs, much appreciate 👍 Let me try to answer you with contexts.
Having said that, yes I agree that now the AppleTV platform seems stable, things like |
@cpwc I'm glad it solves your specific use case. Feel free to open issues and feature requests, any helping hand is much appreciated 🙏 |
Where I can see other menu attributes and options for menu? |
Hi, |
@MarhyCZ, it would be great if you can submit a PR to this, including the update to the readme file mentioning this support 🙏 And do mail me if you would like to get involved with the project as a main contributor, I'm really short of hands and time to take care of everything here 🙅♂️ |
@emadalam I will have it submitted by today! Sorry for delay, holidays :) I really appreciate this offer, but I don´t consider myself as a programmer, I am just basically merging the branches :-D There is no rush in anything, I think the current version is great for a lot of people who want to create content-driven tvOS apps 👍 |
The actual ticket issue has been merged now in the main branch and released as part of #44. Closing this for now. |
Currently
Selecting the menu item loads the previously loaded cached page and there is no way to force reload it based on configuration.
Wanted
Support attribute configuration
reloadOnSelect
to load a non-cached version of the page on every selection.The text was updated successfully, but these errors were encountered: