reactive-programming

The difference between Reactive and Functional-Reactive programming

谁都会走 提交于 2019-12-04 07:24:27
问题 I have been doing some research into reactive programming recently and I'm finding it hard to find a good description of the difference between Reactive and Functional -Reactive. Is it simply that the reactive programming is implemented using functional methods/paradigms as opposed to using declarative or OO paradigms? 回答1: Functional Reactive Programming (FRP) is a specific programming model with a specific semantics. (Actually, there are two variants, which are sometimes called "classic FRP

RxJS: How would I “manually” update an Observable?

你说的曾经没有我的故事 提交于 2019-12-04 07:23:42
问题 I think I must be misunderstanding something fundamental, because in my mind this should be the most basic case for an an observable, but for the life of my I can't figure out how to do it from the docs. Basically, I want to be able to do this: // create a dummy observable, which I would update manually var eventObservable = rx.Observable.create(function(observer){}); var observer = eventObservable.subscribe( function(x){ console.log('next: ' + x); } ... var my_function = function(){

Cache handling with RXJava

二次信任 提交于 2019-12-04 07:06:57
I'm trying to implement this workflow with rxJava but i'm sure if i'm misusing or doing stuff wrong. User asks to login If a loginResult is available in cache then "emit" the cached LoginResult Else actually perform the request to the webservice and cache the result if everything is successfull If an error occurs retry at most 3 times and if there is a 4th time then purge the cache. Here is my full snippet of code. public class LoginTask extends BaseBackground<LoginResult> { private static CachedLoginResult cachedLoginResult = new CachedLoginResult(); private XMLRPCClient xmlrpcClient; private

three interdependent selectInput in R/Shiny application

梦想与她 提交于 2019-12-04 06:33:59
问题 I'm working on a R/Shiny application and one of its features should be to export data based on some filters. However the filters depends on each other. Consider a list of companies, each companies has some teams or departments and these can be located in different countries. The user can filter the data to export through three drop-down menus (selectInput), but I would like that when one dimension (i.e. group) is selected the choices in the drop-down list for the other two dimensions (i.e.

How to easily convert or assign an Observable to a Behavior Subject, so other component can share it

北战南征 提交于 2019-12-04 06:14:04
I am new to Observable style programming. I have a question: I want to share user info across the app between component - and I use BehaviorSubject to share this info. This is inspired by sharing BehaviorSubject as AuthInfo. If I can share AuthInfo which contain a uid across my app component, why can I use it to share my user object data? The problem is, the user object, I am getting that from Firebase. So it is an Observable, and I have no idea how can I assign this to a Behavior Subject. So here is the code I attempted: @Injectable() export class AuthService { static UNKNOWN_USER = new

how to calculate moving average in RxJava

早过忘川 提交于 2019-12-04 05:29:11
In finance domain, we usually need to calculate the moving-window aggregate value from a stream of time series data, use moving average as an example, say we have the following data stream(T is time stamp and V is the actual vlaue): [T0,V0],[T1,V1],[T2,V2],[T3,V3],[T4,V4],[T5,V5],[T6,V6],[T7,V7],[T8,V8],[T9,V9],[T10,1V0],...... to calculate a moving average 3 from the stream we get: avg([T0,V0],[T1,V1],[T2,V2]), avg([T1,V1],[T2,V2],[T3,V3]), avg([T2,V2],[T3,V3],[T4,V4]), avg([T3,V3],[T4,V4],[T5,V5]), avg([T4,V4],[T5,V5],[T6,V6]),... To calculate the moving average, it seems like we could do it

In Rx, how to group events by id and throttle each group by multiple TimeSpans?

∥☆過路亽.° 提交于 2019-12-04 05:25:45
I got into a Rx spree, so to speak, and this question is related to mine here and here . Nevertheless, maybe these are of help to someone as I could see them as useful variations of the same theme. Question: How could one group a random stream of int (say, on interval [0, 10] produced on random interval) objects into groups and provide for earch group a variable number of absence of events alarms (for the lack of better definition, for futher background see linked posts). More specifically with code, how could one define multipe throttle settings per group in the following: var idAlarmStream =

Limiting concurrent access to a service class with RxSwift

南楼画角 提交于 2019-12-04 05:12:09
问题 Given a service class like this: class Service { let networkService = NetworkService() func handleJobA(input: String) -> Observable<ResultA> { return networkService .computeA(input) .map { $0.a } } } And when I use it from the caller side like this: let service = Service() Observable .from(["Hello", "World"]) .flatMap { service.handleJobA($0) } .subscribe() Then this would send multiple requests to service at the same time. I wanted for the stream to wait until each request is done. That was

Streaming in slick/scala

◇◆丶佛笑我妖孽 提交于 2019-12-04 04:59:33
I'm looking at scala/slick streaming, and trying to understand how it works. Here is my test code val bigdata = TableQuery[BigData] val x = db.stream(bigdata.result.transactionally.withStatementParameters(fetchSize = 100)).foreach { (tuple: (Int, UUID)) => println(tuple._1 + " " + tuple._2) Thread.sleep(50)//emulating slow consumer. } Await.result(x, 100000 seconds) While the code is running I enabled postgresql query log to understand whats going under the hood. I see a re-query happening every 100 elements 2015-11-06 15:03:24 IST [24379-3] postgres@scala_test LOG: execute fetch from S_2/C_3:

Marble Diagrams [closed]

牧云@^-^@ 提交于 2019-12-04 04:53:27
The Marble diagrams are frequently from the Rx team explaining how certain operators in Rx work. Are there any tool to create the marble diagrams? I've thought about creating a tool like this a fair bit having created quite a few of them in Visio (look on my blog for examples). I looked around to see if anyone else had done it and couldn't find anything terribly useful. At first blush, it seemed like an obvious tool to write - but I think almost every useful (i.e. complex/interesting) scenario I've worked with has required a uniquely "human" approach to diagram sensibly. 来源: https:/