Skip to content

Conversation

jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Mar 13, 2024

Example:

app.py

from counter import counter

from shiny.express import ui

counter("one")
ui.hr()
counter("two")

counter.py

from shiny import reactive
from shiny.express import module, render, ui


@module
def counter(input, output, session, starting_value=0):
    count = reactive.value(starting_value)

    ui.input_action_button("btn", "Increment")

    with ui.div():

        @render.express
        def current_count():
            count()

    @reactive.effect
    @reactive.event(input.btn)
    def increment():
        count.set(count() + 1)

@jcheng5 jcheng5 changed the title Implement express.module Modules for Shiny Express Mar 13, 2024
@wch wch added this to the v0.9.0 milestone Mar 16, 2024
@wch wch force-pushed the express-modules branch from 3884614 to 7e7c4eb Compare April 22, 2024 21:42
@wch wch marked this pull request as ready for review April 22, 2024 21:43
@wch
Copy link
Collaborator

wch commented Apr 22, 2024

Note that there is a type-checking error, but it seems to be new to pyright 1.1.359 and is unrelated to the changes in this PR.

@wch wch merged commit 124e117 into main Apr 22, 2024
@wch wch deleted the express-modules branch April 22, 2024 21:53
@wch wch mentioned this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants