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

SplitRender.signal should be a lazy val, not def #18

Open
raquo opened this issue Jun 11, 2024 · 0 comments
Open

SplitRender.signal should be a lazy val, not def #18

raquo opened this issue Jun 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@raquo
Copy link
Owner

raquo commented Jun 11, 2024

Example problem from Discord:

    def compPage = compilePage
    val splitter = SplitRender[ToolPage, ToolPageComponents](pageSignal)
        .collectStatic(CompilePage)(compPage)
        div(className := "bottom-grid",
            div(Container,
                div(ContainerTitle,
                    h2("Compiler Input"),
                    child <-- splitter.signal.map(_.submitButton),
                ),
                child <-- splitter.signal.map(_.editor),
            ),
            child <-- splitter.signal.map(_.results),
        )

Because splitter.signal is used three times, and it's a def in Waypoint, that creates three new signals, each of which evaluates compPage by-name separately, resulting in three evaluations per pageSignal event instead of one. This breaks the general shared-execution expectation that is core to Airstream.

Fix will be included in the next release.

Workaround for such cases is to save splitter.signal into a val instead of just splitter.

@raquo raquo added the bug Something isn't working label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant