我无法通过JavaScript的新Streams API从我的WebFlux服务器中获取响应.
我可以通过Curl(在帮助下--limit-rate)看到服务器正在按预期放慢速度,但是当我尝试在Google Chrome(64.0.3282.140)中使用正文时,它并没有像它应该的那样减速.实际上,即使只传递了大约187 kB,Chrome也会从服务器下载并缓冲大约32 MB write().
我的JavaScript有问题吗?
async function fetchStream(url, consumer) {
const response = await fetch(url, {
headers: {
"Accept": "application/stream+json"
}
});
const decoder = new TextDecoder("utf-8");
let buffer = "";
await response.body.pipeTo(new WritableStream({
async write(chunk) {
buffer += decoder.decode(chunk);
const blocks = buffer.split("\n");
if (blocks.length === 1) {
return;
}
const indexOfLastBlock = blocks.length - 1;
for (let index = 0; index < indexOfLastBlock; index ++) {
const block = blocks[index];
const item …Run Code Online (Sandbox Code Playgroud) javascript google-chrome reactive-programming reactive-streams spring-webflux
在模式中使用vector-effect ="non-scaling-stroke"时,我没有在Firefox或Chrome中获得预期的结果,尽管Opera按预期工作...
例:
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" height="100px" width="1000px">
<defs>
<pattern id="ticks" viewBox="0 0 12 4" preserveAspectRatio="none" height="100%" width="10%">
<path stroke="#000" vector-effect="non-scaling-stroke" d="M 0 0 L 0 4 M 1 0 L 1 1 M 2 0 L 2 1 M 3 0 L 3 2 M 4 0 L 4 1 M 5 0 L 5 1 M 6 0 L 6 3 M 7 0 L 7 1 M 8 0 L 8 1 M 9 0 …Run Code Online (Sandbox Code Playgroud) 我想用采用RxJava 1.1.5与Spring WebFlux(即反应堆堆芯3.1.0.M3)库,但我无法适应Observable到Flux。
我以为这是相对简单的,但是我的适配器不起作用:
import reactor.core.publisher.Flux;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
public static <T> Flux<T> toFlux(Observable<T> observable) {
return Flux.create(emitter -> {
final Subscription subscription = observable.subscribe(new Subscriber<T>() {
@Override
public void onNext(T value) {
emitter.next(value);
}
@Override
public void onCompleted() {
emitter.complete();
}
@Override
public void onError(Throwable throwable) {
emitter.error(throwable);
}
});
emitter.onDispose(subscription::unsubscribe);
});
}
Run Code Online (Sandbox Code Playgroud)
我已经验证过,onNext并且onCompleted都以正确的顺序被调用,但是我Flux始终是空的。有人看到我在做什么错吗?
在相关说明中,为什么反应堆插件中没有RxJava 1适配器?