reactive-programming

Reset timeout on event with RxJS

感情迁移 提交于 2019-12-06 04:35:57
I'm experimenting with RxJS (with the JQuery extension) and I'm trying to solve the following use case: Given that I have two buttons (A & B) I'd like to print a message if a certain "secret combination" is clicked within a given timeframe. For example the "secret combination" could be to click "ABBABA" within 5 seconds. If the combination is not entered within 5 seconds a timeout message should be displayed. This is what I currently have: var secretCombination = "ABBABA"; var buttonA = $("#button-a").clickAsObservable().map(function () { return "A"; }); var buttonB = $("#button-b")

Setting up data refreshing in Shiny app connected to PostgreSQL

岁酱吖の 提交于 2019-12-06 04:27:56
I've looked at this and this thread and a few others but haven't been able to figure out my solution. I have built a dashboard using R and Shiny, and said dashboard pulls in data from a Postgres db using the RPostgreSQL package. Right now, the code for all the data pulling and analysis is done outside of the shinyServer function, and only the displaying part (the output and render functions) is in the shinyServer portion. I'd like to set it up so that the dashboard data is periodically refreshed and the charts are updated. I've looked into reactivePoll and invalidateLater and understand them,

How to observe network changes in RxAndroid

六眼飞鱼酱① 提交于 2019-12-06 04:18:36
问题 I’m using the code given here. I put those code blocks as classes in my project’s util package. And then in the main activity class I wrote this.. class MenuActivity { // Variable declaration private final CompositeSubscription mConnectionSubscription = new CompositeSubscription(); @Override protected void onCreate(Bundle savedInstanceState) { // Some initialisation of UI elements done here mConnectionSubscription.add(AppObservable.bindActivity(this, NetworkUtils.observe(this)).subscribe(new

With Reactive Extensions (RX), is it possible to add a “Pause” command?

落花浮王杯 提交于 2019-12-06 03:47:23
问题 I have a class which takes in a stream of events, and pushes out another stream of events. All of the events use Reactive Extensions (RX). The incoming stream of events is pushed from an external source into an IObserver<T> using .OnNext , and the outgoing stream of events is pushed out using IObservable<T> and .Subscribe . I am using Subject<T> to manage this, behind the scenes. I am wondering what techniques there are in RX to pause the output temporarily. This would mean that incoming

Understanding back-pressure in rxjs - only cache 5 images waiting for upload

我只是一个虾纸丫 提交于 2019-12-06 03:24:03
问题 I am working on a node project that needs to submit thousands of images for processing. Before these images are uploaded to the processing server they need to be resized so I have something along the lines of this: imageList .map(image => loadAndResizeImage) .merge(3) .map(image => uploadImage) .merge(3) .subscribe(); Image resizing typically takes a few tenths of a second, uploading and processing takes around 4 seconds. How can I prevent thousands of resized images building up in memory as

ggvis plots rendered using bind_shiny() aren't reactive

允我心安 提交于 2019-12-06 02:35:09
I think I'm missing some basic aspect of ggvis + shiny. Following the tutorials, plots are constructed in server.R using a series of %>% pipes, ending with bind_shiny, which associates the plot with an identifier that can be referred to in ui.R What I don't get though is that the plot itself is not reactive in the way that code within renderTable(), renderText() or reactive() will be. So if I want to refer to an input parameter like input$x in defining the plot, it won't work, I'll get an error saying "Operation not allowed without an active reactive context. (You tried to do something that

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

笑着哭i 提交于 2019-12-06 01:57:16
问题 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

Fighting with FRP

拈花ヽ惹草 提交于 2019-12-06 01:31:02
问题 I've read about FRP and was very excited. It looks great, so you can write more high-level code, and everything is more composable, and etc. Then I've tried to rewrite my own little game with a few hundreds sloc from plain js to Bacon. And I found that instead of writing high-level logic-only code, I actually beating with Bacon.js and its adherence to principles. I run into some headache that mostly interfere clean code .take(1) Instead of getting value, I should create ugly constructions.

Is it possible to build a Reactive Application using a non-Functional language?

痴心易碎 提交于 2019-12-06 01:07:14
I would like to understand if the principles behind the Reactive Application manifesto can be achieved using a non-functional language . Some people say that since FP use immutable states and free side-effects functions, they are easier to implement concurrent, distributed and resilient systems. But how can we achieve that using Java for example? There are some frameworks like Apache Camel, that have some components to work with, like Camel RX , and Camel SEDA . Are these frameworks enough? I will try to clarify my question: I think of reactive programming as new programming paradigm, and a

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

让人想犯罪 __ 提交于 2019-12-06 00:51:13
问题 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