R Shiny点击事件和渲染图之间的反应无限循环

时间:2018-04-26 12:58:57

标签: r shiny infinite-loop reactive

这应该是非常简单的我之前已经解决了这个问题,但是对于我的生活不能记得如何。

基本上,在下面的代码中,在GGplot中生成的平板地图上有一个点击事件。

click事件修改原始数据数据框(keepRows)中的最后一列。 这再次调用abstract class BaseManager[T <: Container[_]]( val storage: ContentStorage[T#ContentType] ) extends Actor with Manager[T] { def withContents(container: T, content: ContentType): ContainerType def withoutContents: T var container: T = withoutContents def receive: Receive { case ContentsChanged => container = withContents(container, storage.get) case ContainerRequester => sender ! container // ... other common actions } } class FooManager(storage: FooStorage) extends BaseManager[FooContainer](storage) { def withContents(container: FooContainer, content: Foo) = container.copy(Some(content)) def withoutContent = FooContainer(None) override def receive: Receive = super.receive orElse { // some additional actions, specific to Foo } } case class FooContainer(content: Option[Foo]) extends Container[Foo]{ // some extremely expensive calculations that happen when // content is assigned, so that we can cache the result in container } 函数来更新绘图(将改变绘图的代码尚不存在)

我遇到的问题是,当output$PlateMap <- renderPlot({...})运行时,它会导致反应事件再次调用output$PlateMap <- renderPlot({...})事件,从而导致无限循环。

observe({...})

1 个答案:

答案 0 :(得分:0)

我发现了隔离整行所需的问题:

rv$RawData$keepRows <- xor(isolate({rv$RawData$keepRows}), res$selected_)

喜欢:

isolate({rv$RawData$keepRows <- xor(rv$RawData$keepRows, res$selected_)})