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

nested render on tracker() throws UnsupportedOperationException in Browser #405

Closed
WestHuus opened this issue May 27, 2021 · 2 comments · Fixed by #530
Closed

nested render on tracker() throws UnsupportedOperationException in Browser #405

WestHuus opened this issue May 27, 2021 · 2 comments · Fixed by #530
Assignees
Labels
bug Something isn't working

Comments

@WestHuus
Copy link
Collaborator

See example Code

  @ExperimentalCoroutinesApi
fun main() {
    val store = object : RootStore<String>("...") {
        val running = tracker()
        val start = handle {
            running.track("init") {
                delay(1500)
                "store"
            }
        }

        init {
            start()
        }
    }
    val otherStore = object : RootStore<String>("") {
        val running = tracker()
        val start = handle {
            running.track("init") {
                delay(600)
                "otherStore"
            }
        }

        init {
            start()
        }
    }

    store.watch()
    otherStore.watch()

    //not works
    render {
        store.running("init").render {
            div {
                otherStore.running("init").render {
                    store.data.render {
                        span { +it }
                    }
                }
            }
        }
    }
 
    //works
/**
    render {
        store.running("init").render {
            div {
                otherStore.running("init").render {
                    div {
                        store.data.render {
                            span { +it }
                        }
                    }
                }
            }
        }
    }
*/
}
@WestHuus WestHuus added the bug Something isn't working label May 27, 2021
@Pitel
Copy link

Pitel commented Jun 18, 2021

I have something similar, but without tracker:

fun RenderContext.foo() {
  val store = storeOf(false)

  div { // It's broken without this div!
    store.data.render {
      p { +"$it }
    }
  }

  clickButton {
    text("Toggle")
  }.map { !store.current } handledBy store.update
}

At first it looks ok. But after clicking the button, I get the UnsupportedOperationException and the text "true" appears after the button (while the inital "false" stays above the button).

(The code is heravily simplified and untested, )

@jillesvangurp
Copy link
Contributor

jillesvangurp commented Oct 12, 2021

@Pitel thanks for the workaround, running into exactly this as well with fritz2 0.12. Adding a div around any store.data.render works

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

Successfully merging a pull request may close this issue.

4 participants