Skip to content

Add example for nested modules #1303

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

Open
ME-researchgroup opened this issue Apr 11, 2024 · 3 comments
Open

Add example for nested modules #1303

ME-researchgroup opened this issue Apr 11, 2024 · 3 comments

Comments

@ME-researchgroup
Copy link

ME-researchgroup commented Apr 11, 2024

Hi!

I am writing an application and would like to split my code into different modules to keep it organized.

For my use case, the user can press a button who's logic lives in "app.py" with its own ui and server. Clicking the button will open a modal who's logic lives in its own file with its own ui and server, the modal introduces new buttons and each button has its own logic in their respective files with their own ui and server components.

I can get the modal working, but when I go one layer deeper i can't seem to get it to work; nothing happens when the buttons are clicked.
I guess I am confused about how the namespace is resolved/how i should handle IDs and found the documentation lacking for more complex architectures.

Any chance we could add an example for nested modules? In the meantime it would really help me if someone could give a code example of how i could get this to work.

Thanks in advance!

@gadenbuie
Copy link
Collaborator

Hi @ME-researchgroup! Do you think you could create a small example using the pattern you're trying to get working? It could be a question of getting the nested modules set up correctly, or it could be an issue with the modal logic.

@ME-researchgroup
Copy link
Author

Hi @gadenbuie , i'll try to write an example this week. The code works if i put everything in app.py, so I think the logic should be fine. Also, I've now got it to work by using resolve_id() so I am pretty sure it's a namespace issue. So it works for now, but since resolve_id is defined in the _namespaces folder, I don't think that's what I'm supposed to do :)

@teristam
Copy link

teristam commented Jul 11, 2024

Hi, is there any update on this? I am having similar problems creating nested modules. Specifically, I don't really know where to put the server functions of the sub-module. I tried to create it in the parent modules but it the server function requires reactive input and shiny complains about not having a reactive context when the app starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants