我正在尝试通过Heinrich Apfelmus的反应性香蕉来了解FRP ,与我所看到的其他相比,它似乎是一个文档齐全且简单的库.
但是,我无法绕过AddHandler类型.假设我想使用GLFW来获取鼠标按钮,以便我有类似的东西eMouseButton :: Event ().看看这些例子,似乎我不得不使用fromAddHandler,但我不知道如何组装该AddHandler参数.我想我不得不以newAddHandler某种方式使用,但是怎么样?
我想一个如何连接reactive-banana到其他东西的例子wx会有很大帮助.
我正在尝试获取给定的最新值,Observable并在调用后立即将其发出.以下面的代码为例:
return Observable.just(myObservable.last())
.flatMap(myObservable1 -> {
return myObservable1;
})
.map(o -> o.x) // Here I want to end up with a T object instead of Observable<T> object
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为通过这样做,flatMap将发射myObservable1,然后必须发射,以达到map.我不知道是否可以做这样的事情.有没有人知道如何实现这一目标?谢谢
在测试方法中的实例org.springframework.web.reactive.function.client.ClientRequest在测试方法中接收 的
我想验证它的 HttpMethod、URI 和正文。
如何获得除了身体以外的一切,这是很明显的。
ClientRequest request = makeInstance(...);
assertEquals(HttpMethod.POST, request.method());
assertEquals("somewhere/else", request.url().toString());
// ? unclear how to extract body using the BodyInserter
BodyInserter<?, ? super ClientHttpRequest> inserter = request.body();
inserter.insert(%outputMessage%, %context%);
Run Code Online (Sandbox Code Playgroud)
我在Spring的源代码中找到了如何测试BodyInserters。或多或少清楚如何创建BodyInserter.Context(第二个参数),但我不明白如何构造第一个参数,因此可以通过它提取请求正文。
请展示一种从实例获取请求正文的传统(或至少可用)方法ClientRequest。
所以我正在做一个相当复杂的javascript/html客户端,有很多ajax调用和callback-ism的其他参与.我很乐意为此目的使用Fay.我知道榆树.试过它并喜欢FRP元素.现在我想知道Fay是否有类似的结构.
此时Fay的FRP有没有具体的例子?
编辑:迁移到Programmers.Stackexchange:https://softwareengineering.stackexchange.com/questions/186102/functional-reactive-programming-is-fay-expressive-enough
javascript haskell functional-programming reactive-programming fay
在功能反应式编程的上下文中,"毛刺"的定义是什么?
我知道在一些FRP框架中可能会发生"故障",而在其他框架中则不会.例如,RX不是无干扰,而ReactFX是无干扰的[ 1 ].
有人可以给出一个非常简单的例子,演示如何以及何时使用RX时出现毛刺,并在同一示例中显示相应的ReactFX解决方案如何以及为何无故障.
谢谢阅读.
terminology reactive-programming system.reactive rx-java reactfx
我正在尝试减少该组件的宽度:
https://github.com/callemall/material-ui/blob/master/src/TextField/TextField.jsx
这是渲染方法:
render() {
return (
<div>
<div>
<form onSubmit={this.handleSubmit}>
<TextField
hintText="Email"
ref="email"
/><br/>
<TextField
hintText="Password"
type="password"
ref="password"
/><br/>
<button className="btn btn-success" onClick={this.loginCommand}><i className="fa fa-sign-in"/>{' '}Log In</button>
</form>
</div>
}
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢 !
我正在尝试WebClient使用反应式编程的代码库中的Spring 5(5.0.0.RC2)中的新内容,并且我已成功将JSON响应从端点映射到我的应用程序中的DTO,这非常好用:
WebClient client = WebClient.create(baseURI);
Mono<DTO> dto = client.get()
.uri(uri)
.accept(MediaType.APPLICATION_JSON)
.exchange()
.flatMap(response -> response.bodyToMono(DTO.class));
Run Code Online (Sandbox Code Playgroud)
但是,现在我正在尝试使用协议缓冲区(二进制数据作为application/octet-stream)的端点的响应体,所以我想从响应中获取原始字节,然后我将自己映射到一个对象.
我Bytes从Google Guava 那里得到了这样的工作方式:
Mono<byte[]> bytes = client.get()
.uri(uri)
.accept(MediaType.APPLICATION_OCTET_STREAM)
.exchange()
.flatMapMany(response -> response.body(BodyExtractors.toDataBuffers()))
.map(dataBuffer -> {
ByteBuffer byteBuffer = dataBuffer.asByteBuffer();
byte[] byteArray = new byte[byteBuffer.remaining()];
byteBuffer.get(byteArray, 0, bytes.length);
return byteArray;
})
.reduce(Bytes::concat)
Run Code Online (Sandbox Code Playgroud)
这有效,但是有更简单,更优雅的方式来获取这些字节吗?
java spring binary-data protocol-buffers reactive-programming
我在相同的通量上使用 publishOn 和 subscribeOn,如下所示:
System.out.println("*********Calling Concurrency************");
List<Integer> elements = new ArrayList<>();
Flux.just(1, 2, 3, 4)
.map(i -> i * 2)
.log()
.publishOn(Schedulers.elastic())
.subscribeOn(Schedulers.parallel())
.subscribe(elements::add);
System.out.println("-------------------------------------");
Run Code Online (Sandbox Code Playgroud)
虽然,当我同时使用两者时,日志中没有打印任何内容。但是当我只使用 publishOn 时,我得到了以下信息日志:
*********Calling Concurrency************
[info] | onSubscribe([Synchronous Fuseable] FluxArray.ArraySubscription)
[info] | request(256)
[info] | onNext(1)
[info] | onNext(2)
[info] | onNext(3)
[info] | onNext(4)
[info] | onComplete()
-------------------------------------
Run Code Online (Sandbox Code Playgroud)
是不是publishOn 比subscribeOn 更值得推荐?或者它比 subscribeOn 有更多的偏好?两者有什么区别以及何时使用哪个?
publisher publish-subscribe reactive-programming project-reactor reactive-streams
我使用spring boot webflux+ project reactor+lettuce连接和非阻塞方式查询Redis的。我已经配置了ReactiveRedisTemplate带LettuceConnectionFactory。spring 文档指出,使用管道的唯一方法ReactiveRedisTemplate是使用该execute(<RedisCallback>)方法。在 non-reactive 中RedisTemplate,我看到有一种executePipelined(<RedisCallback>)方法可以在执行回调之前打开/关闭管道。但是在ReactiveRedisTemplate.execute方法的情况下,它使用 aLettuceReactiveRedisConnection并且既Spring ReactiveRedisConnection没有Lettuce也没有没有对管道的引用。
所以我的问题是,是否可以在使用Spring ReactiveRedisTemplate+时流水线化您的命令ReactiveLettuceConnection?
我也注意到,使用ReactiveRedisTemplate.execute了RedisCallback具有多个Redis命令的执行速度比打电话只是单独的命令慢。
带有 ReactiveRedisTemplate 的管道示例代码:
reactiveRedisTemplate.execute(connection -> keys.flatMap(key ->
connection.hashCommands()
.hGetAll(ByteBuffer.wrap(key.getBytes()))))
.map(Map.Entry::getValue)
.map(ByteUtils::getBytes)
.map(b -> {
try {
return mapper.readValue(b, Value.class);
} catch (IOException e1) {
return null;
}
})
.collectList();
Run Code Online (Sandbox Code Playgroud)
没有管道的代码:
keys.flatMap(key -> reactiveRedisTemplate.opsForHash().entries(key))
.map(Map.Entry::getValue) …Run Code Online (Sandbox Code Playgroud) reactive-programming redis lettuce spring-data-redis project-reactor
我想在一个项目中使用2种方法(反应式和标准式)。
我尝试将一个REST API端点迁移到反应式Webflux并测试性能,然后再迁移其余的。但这没有用。我为他添加了路由器和处理程序,但是直到我没有spring-boot-starter-web从依赖项中删除并禁用 @RestController我,我一直404都得到了HTTP 代码。有没有可能?还是应该将所有项目迁移到被动方法?
java reactive-programming spring-boot project-reactor spring-webflux
java ×4
haskell ×2
javascript ×2
rx-java ×2
spring ×2
binary-data ×1
fay ×1
lettuce ×1
material-ui ×1
publisher ×1
reactfx ×1
reactjs ×1
redis ×1
rx-android ×1
spring-boot ×1
terminology ×1