Skip to content
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

Module() server functions don't return a value when invoked #102

Closed
cpsievert opened this issue Mar 3, 2022 · 0 comments · Fixed by #100
Closed

Module() server functions don't return a value when invoked #102

cpsievert opened this issue Mar 3, 2022 · 0 comments · Fixed by #100

Comments

@cpsievert
Copy link
Collaborator

For example, this should print "return value"

from typing import Callable
from shiny import *
from shiny.modules import *


def my_ui(ns: Callable[[str], str]) -> ui.Tag:
    return ui.input_action_button(ns("btn"), "Press")


def my_server(input: ModuleInputs, output: ModuleOutputs, session: ModuleSession):
    @reactive.Effect()
    def _():
        print(input.btn())

    return "return value"


my_module = Module(my_ui, my_server)

app_ui = ui.page_fluid(my_module.ui("foo"))


def server(input: Inputs, output: Outputs, session: Session):
    val = my_module.server("foo")
    print(val)


app = App(app_ui, server)
@cpsievert cpsievert changed the title Module() server function return value is inaccessible Module() server functions don't return a value when invoked Mar 3, 2022
cpsievert added a commit that referenced this issue Mar 8, 2022
…nd have custom arguments (and also allow UI functions to have keyword arguments)
@wch wch closed this as completed in #100 Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant