现在微软已经在devlabs上发布了适当版本的Rx框架,这个问题已经不再适用了
原始问题
我已经下载了Silverlight 3工具包并重新定义了System.Reactive.dll,以便在.NET 3.5 CLR上工作,我真的很享受使用它.
我想知道的是,我可以发货吗?
我想我可以在MS-PL许可下发货,但同时感觉我不应该,因为我不得不重新设置dll,因为我还没有看到任何微软关于发布反应框架的官方消息.
另一种选择是要么IObservable直到.NET 4.0,或者编写我自己的系统ripoff版本.我可能最终会编写一个ripoff版本,即使这会浪费一些时间.
有没有其他人想过这个问题,是否有其他人使用/运送该DLL?
我使用System.IO.Pipes(控制台应用程序和GUI应用程序)在同一台计算机上建立了两个独立进程之间的通信.控制台应用程序NamedPipeServerStream在GUI应用程序NamedPipeClientStream连接到现有管道时创建管道.我经常更新GUI.我的问题是,命名管道技术是处理这种情况最有效的方法.第二个问题是Reactive Extensions RX是否适合这种情况以及如何?先感谢您.
服务器
using System;
using System.IO;
using System.IO.Pipes;
using System.Threading;
namespace PipeApplicationSender
{
class ProgramPipeTest
{
static void Main(string[] args)
{
ProgramPipeTest Server = new ProgramPipeTest();
Thread ServerThread = new Thread( Server.ThreadStartServer );
ServerThread.Start();
}
public void ThreadStartServer()
{
// Create a name pipe
using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("mytestpipe"))
{
// Wait for a connection
pipeStream.WaitForConnection();
Console.WriteLine("[Server] Pipe connection established");
using (StreamReader sr = new StreamReader(pipeStream))
{
string temp;
// We read a line from the pipe …Run Code Online (Sandbox Code Playgroud) 我正在使用闪亮构建一个Web应用程序,我不确定如何最好地构建应用程序,因为输入依赖于数据,输出(图表)依赖于基于输入的聚合数据.
我试图想出一个简单的应用程序来重现问题.我的设置更高级,与示例无关.假设您有一个产品系列并想分析销售情况.假设每天都创建一个数据集(我不是说数据结构是最优的,但它对于说明我的问题很有用).现在,在应用程序中,从可用日期列表中选择一个日期,然后选择一个产品.日期仅限于可用数据的期间,产品列表仅限于在选定日期实际销售的产品.然后,我们希望绘制白天每小时的总销售额.
我将列出下面这样一个示例的一些代码,其中还创建了一些示例数据.对不起"长"代码.它有点工作,但我有一些担忧.
我的问题是:
1)我想知道事情的执行顺序,特别是首次加载应用程序时,以及每次输入更改时.同样,数据取决于第一输入,第二输入取决于数据.第三,计算用于图表的图表友好数据集.您可能会注意到错误会打印到控制台(并在浏览器中短暂闪烁),但是当值可用时,会进行更新并显示图表.这似乎不是最理想的.
2)当输入依赖于数据/服务器时,当前的最佳实践是什么.R?我看到这个https://groups.google.com/forum/?fromgroups=#!topic/shiny-discuss/JGJx5A3Ge-A但似乎这没有实现,甚至以为后已很旧.
这是两个文件的代码:
# ui.R
######
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("New Application"),
sidebarPanel(
htmlOutput("dateInput"),
htmlOutput("prodInput")
),
mainPanel(
plotOutput("salesplot")
)
))
Run Code Online (Sandbox Code Playgroud)
和:
#server.R
#########
library(shiny)
library(filehash)
set.seed(1)
dates <- format(seq(Sys.Date() - 10, Sys.Date(), "days"), "%Y-%m-%d")
products <- LETTERS
prices <- sample(10:100, size = length(products), replace = TRUE)
names(prices) <- LETTERS
if (file.exists("exampledb")) {
db <- dbInit("exampledb")
} else {
dbCreate("exampledb")
db <- dbInit("exampledb")
for (d in dates) {
no.sales <- sample(50:100, size = 1)
x <- data.frame( …Run Code Online (Sandbox Code Playgroud) 我在过滤依赖于多个数字输入的无功数据集时遇到了一些麻烦.有没有可用的方法?我在下面提供了类似的代码,它复制了我想要实现的任务.
ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("abc"),
sidebarLayout(
sidebarPanel(
numericInput("first", "A",0),
numericInput("second", "B",0),
numericInput("third", "C",0),
numericInput("fourth", "D",0),
numericInput("fifth", "E",0),
actionButton("mybutton","Submit")
),
mainPanel(
tableOutput("mytable")
)
)
))
server.R
library(data.table)
library(shiny)
library(stats)
shinyServer(function(input, output) {
a<-c("A","B","C","D","E","F","G")
b<-c("10","20","30","40","50","60","70")
ab<-data.frame(a,b)
a<-c("A","B","C","D","E")
input_vector<-reactive({
c(input$first,input$second,input$third,input$fourth,input$fifth)
})
newdata<-reactive({
data.frame(a,input_vector())
})
merged_data<-reactive({
merge(newdata(),ab,by.newdata=a)
})
mutated_data<-reactive({
library(dplyr)
merged_data%>% #using merged()%>% gives error "Warning in Ops.factor(function () : ‘*’ not meaningful for factors"
mutate(newvalue=input_vector*b) #using merged%>% gives error "no applicable method for 'mutate_' applied to an object of class "reactive"
})
output$mytable<-renderTable({ …Run Code Online (Sandbox Code Playgroud) 我有两个具有不同泛型类型的Observable:Observable o1和Observable o2
我被定义为o1 onComplet()和onNext()函数,我希望当这个Observable完成后,o2就可以启动了.
我尝试了Observable.concat(),但它们有不同的类型,所以这种方法不起作用......
那我该怎么做?
我在演示中学习了一个例子来创建一个UITableView并渲染单元格.
在我看来,items是viewModel,我想通过使用Alamofire或其他库来请求跨网络的一些数据.当我收到回复时,如何更新相关单元格的文本?
换句话说,我想将viewModel绑定到Cells.当模型的数据发生变化时,单元格的内容可能会自动更改.
我有一个想法是:为单元格的内容创建一个Observable序列(绑定到单元格).当服务器响应数据时,它调用函数tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top).但这似乎不是一种优雅或好的方法.
所以,希望有些人可以帮助我:)
let items = Observable.just([
"First Item",
"Second Item",
"Third Item"
])
items
.bindTo(tableView.rx_itemsWithCellIdentifier("Cell", cellType: UITableViewCell.self)) { (row, element, cell) in
cell.textLabel?.text = "\(element) @ row \(row)"
/* to do some binding or something else ? */
}
.addDisposableTo(disposeBag)
tableView
.rx_modelSelected(String)
.subscribeNext { value in
DefaultWireframe.presentAlert("Tapped `\(value)`")
}
.addDisposableTo(disposeBag)
Run Code Online (Sandbox Code Playgroud) 假设我有一个处理器,当按下按钮时会发出一个布尔值,将其视为切换.
boolean gateValue = true;
PublishProcessor<Boolean> gate = PublishProcessor.create();
view.onButtonClicked()
.subscribe(new Action1<Void>() {
@Override
public void call(final Void aVoid) {
gate.onNext(gateValue = !gateValue);
}
}));
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用门的值来暂停和恢复可观察的序列,在暂停时缓冲发出的值.
我已经阅读了很多内容,虽然它似乎可以在其他语言的反应式扩展中使用,但RxJava似乎并不支持它.
这是我想要实现的一个例子,它只是每秒输出一个增量值.当我按下按钮时,我希望输出停止,直到我再次按下它,这将输出两次按下按钮之间发出的每个项目:
Flowable.interval(1, TimeUnit.SECONDS)
.bufferWhile(gate)
.flatMapIterable(longs -> longs)
.subscribe(new Consumer<Long>() {
@Override
public void accept(final Long aLong) throws Exception {
view.displayTime(aLong);
}
});
Run Code Online (Sandbox Code Playgroud)
有谁知道如何实现这样的事情?
编辑我写了一篇关于如何实现这个的博客文章https://medium.com/@scottalancooper/pausing-and-resuming-a-stream-in-rxjava-988a0977b771#.gj7fsi1xk
是否有一个RxJS中的运算符在不延迟"突发中的第一个事件"的情况下进行去抖动,但延迟(并且始终发出)"突发中的最后一个事件"?
像这样的东西:
---a----b-c-d-----e-f---
之后awesome-debounce(2 dashes)成为:
---a----b------d--e----f
而正常的去抖将是:
-----a---------d-------f
这是油门和去抖之间的混合......
首先,我必须说我对反应式编程没有多少经验.
由于JDK 9(Flow及其嵌套接口)中只有少数接口,因此JDK 9显然不包含像RxJava这样的反应库.
在Javadoc,有对的implentations一些例子Publisher,Subscription和Subscriber.但这些似乎相当低级,没有任何反应操作员或处理背压.
那么将这些接口包含在JDK中有什么意义呢?
反应库的供应商是否应该使用它们,以便那些Java实现(如RxJava)使用一组通用的接口?(类似于JPA和Hibernate?)
我需要使用Oracle数据库和Spring,我可以轻松选择Spring Data JPA,但我的所有程序都应该是被动的.
就像Spring支持Couchbase和Mongo的Reactive Repositories,如本链接所述,请帮我启用Oracle的Reactive Repositories.
我已经尝试从存储库接口扩展ReactiveCrudRepository,但由于Spring Data JPA没有实现反应式API方法,因此失败了.