我想将jquery UI与shiny(不使用shinyjqui库)一起使用。当我有一个图层并尝试使用 jqueryUI 移动它时,它工作得很好,但是当使用 insertUI 动态生成该图层时,它就不起作用了。
\n\n这是代码:
\n\nlibrary(shiny)\n\nui <- fluidPage(theme = "style.css",\n tags$script(src = "jquery-ui.js"),\n tags$script(src = "script2.js"),\n actionButton("add","Add layer"),\n div(class="aux"),\n div(id="works",style="width:300px;height:200px;background:red"))\n\n\n\nserver <- function(input, output, session) {\n\n observeEvent(input$add,{\n insertUI(\n selector = ".aux",\n where="afterEnd",\n ui = div(id=paste0("new",input$add),style="width:300px;height:200px;background:blue")\n\n )\n\n\n })\n\n\n\n\n\n\n}\nshinyApp(ui, server)\nRun Code Online (Sandbox Code Playgroud)\n\n以及js脚本
\n\n $( function() {\n\n\n $("#works").draggable();\n $("#new1").draggable();\n\n\n });\nRun Code Online (Sandbox Code Playgroud)\n\n谢谢!
\n我有一个 inputButton,当您单击它时,完成了对 mysql 数据库的 2 次查询。一个是重的(超过 10 秒),另一个是轻的(小于 0.01 秒获取数据)。
由于我想在闪亮的应用程序上显示此查询的结果,因此我打算使用 Promises 和 Future 包进行异步加载。
在我向您展示我的代码的示例中,我使用函数HeavyFunction模拟了 SQL 查询,该函数旨在模拟繁重的查询和一次加载的ligth。
问题是这段代码对我不起作用,因为在完成重查询之前不会显示轻查询的结果。
注意:在 Rstudio 控制台中,此代码完美运行...
library(future)
library(promises)
plan(multiprocess)
heavyFunction <- function(n){
Sys.sleep(n)
print(n)
}
ui <- fluidPage(
actionButton("go","Show the data"),
textOutput("result0sec"),
textOutput("result10sec")
)
server <- function(input,output,session){
data0 <- eventReactive(input$go,{
heavyFunction(0)
})
data10 <- eventReactive(input$go,{
heavyFunction(10)
})
output$result0sec <- renderText({
data <- data0()
future(data)%...>%print()
})
output$result10sec <- renderText({
data <- data10()
print(data)
})
}
shinyApp(ui,server)
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
我想使用具有某些限制的实体框架进行查询。问题是,有时没有限制,所以我不知道我的做法是否是最佳实践。
我的EF代码如下:
Get(x => x.CreationDate >= filterInit
&& x.CreationDate <= filterEnd
&& x.Cond1 > ax
&& x.Cond2 > y).ToListAsync();
Run Code Online (Sandbox Code Playgroud)
例如,如果ax为null,则执行此操作:
if(ax == null){
Get(x => x.CreationDate >= filterInit
&& x.CreationDate <= filterEnd
&& x.Cond2 > y).ToListAsync();
}else if(y == null)
{
Get(x => x.CreationDate >= filterInit
&& x.CreationDate <= filterEnd
&& x.Cond1 > ax ).ToListAsync();
}else{
Get(x => x.CreationDate >= filterInit
&& x.CreationDate <= filterEnd
&& x.Cond1 > ax
&& x.Cond2 > y).ToListAsync();
}
Run Code Online (Sandbox Code Playgroud)
我敢肯定有一个不错的方法可以做到这一点,但是我不知道怎么做。
你能帮我这个忙吗?