reactive-programming

RxJava-file and operator chaining

老子叫甜甜 提交于 2020-05-27 06:19:09
问题 I'm trying to reactively tail a log file using RxJava-File: File file = new File(".\\server.log"); Observable<String> newLines = FileObservable.tailer() .file(file) .startPosition(file.length()) .sampleTimeMs(1000) .chunkSize(8192) .utf8() .tailText(); newLines.subscribe(System.out::println); and it works as expected. But as soon as I try to chain some more operators, I get problems. For instance, changing to newLines.filter(LogfileWatcher::error).subscribe(System.out::println); (where error(

publishOn vs subscribeOn in Project Reactor 3

久未见 提交于 2020-05-25 08:00:31
问题 I am using publishOn vs subscribeOn both on the same flux as follows: 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("-------------------------------------"); Although, when i use both, nothing is printed in logs. But when i use only publishOn, i got the following info logs:

Send message only to certain client using websockets with Rsocket and Spring Webflux

孤街浪徒 提交于 2020-05-24 03:28:47
问题 I am trying to use Rsocket with websocket in one of my POC projects. In my case user login is not required. I would like to send a message only to certain clients when I receive a message from another service. Basically, my flow goes like this. Service A Service B |--------| websocket |------------------| Queue based comm |---------------| | Web |----------------->| Rsocket server |--------------------->| Another | | |<-----------------| using Websocket |<---------------------| service | |---

How REST endpoints are auto subscribed while calling from Browser/REST Client?

限于喜欢 提交于 2020-05-23 09:21:40
问题 In ProjectReactor or Reactive Streams, Nothing Happens Until You subscribe(). Reactive streams data flow will not happen unless until someone subscribe to it, but I see for all REST APIs like finds, save and inserts are not calling subscribe explicitly but data is flowing between producer and subscribers. @RestController class PersonController { private final PersonRepository repository; public PersonController(PersonRepository repository) { this.repository = repository; } @GetMapping("/all")

I am getting a unique key prop warning when i have a unique key

二次信任 提交于 2020-05-16 03:42:48
问题 I am new to React but I know main concept of unique key. However, I am getting a warning. Below I have an item component: class Item extends Component { state = {} render() { return ( <React.Fragment> {this.props.item.todo} </React.Fragment> ); } } And below is my items component and where i have unique keys: render() { const { items } = this.props; return ( items.map(item=> <React.Fragment> <Item key={item.todo} item={item} /> </React.Fragment> ) ); } With all of this I am getting warning!

Can I use SpringMvc and webflux together?

天大地大妈咪最大 提交于 2020-05-09 19:38:43
问题 I would like to use 2 approaches(reactive and standard) in one project. I tried to migrate one REST API endpoint to reactive webflux and test performance before migrate rest of them. But it didn't work. I added router and handler for him, but until I didn't remove spring-boot-starter-web from dependencies and disable @RestController I got http 404 code all the time. Is it possible or not? Or should I migrate all project to reactive approach? 回答1: As explained in the Spring Boot reference

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

拥有回忆 提交于 2020-03-12 06:57:31
问题 Currently, I am using an EventBus/PubSub architecture/pattern with Scala (and JavaFX) to implement a simple note organizing app (sort of like an Evernote client with some added mind mapping functionality) and I have to say that I really like EventBus over the observer pattern. Here are some EventBus libraries : https://code.google.com/p/guava-libraries/wiki/EventBusExplained http://eventbus.org (currently seems to be down) this is the one I am using in my implementation. http://greenrobot

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

跟風遠走 提交于 2020-03-12 06:57:08
问题 Currently, I am using an EventBus/PubSub architecture/pattern with Scala (and JavaFX) to implement a simple note organizing app (sort of like an Evernote client with some added mind mapping functionality) and I have to say that I really like EventBus over the observer pattern. Here are some EventBus libraries : https://code.google.com/p/guava-libraries/wiki/EventBusExplained http://eventbus.org (currently seems to be down) this is the one I am using in my implementation. http://greenrobot

Chaining method calls using RxJava

你说的曾经没有我的故事 提交于 2020-03-05 07:51:13
问题 Given two methods, both which returns a Single , what is the correct way, using Rx , to chain the two method calls together so that one method is called first, and the second once, and only if, the first completes successfully. Ideally, the second method will be able to access the value returned by the first. 回答1: Assuming your methods are like this: static Single<String> method1() { return Single.just("x"); } static Single<String> method2(String in) { return Single.just(in+"y"); } the

Pagination / Infinite scrolling in Flutter with caching and realtime invalidation

筅森魡賤 提交于 2020-02-15 06:33:41
问题 It's been a long time since I started to search for a Flutter ListView library that will allow me to use pagination in a smart way. Sadly I haven't found anything that meets my criteria: Smart pagination : the library should't simply increase a list page-by-page but must have a fixed size cache which load and keep in memory only the needed pages in the moment. Asyn loading : the library should basically accept a function which returns a future of a list representing a page. Real-time