reactive-programming

Missing Script Start

醉酒当歌 提交于 2019-12-11 14:52:49
问题 I'm trying to run this example. I have these errors when I start running it: npm ERR! missing script: start npm ERR! A complete log of this run can be found in: npm ERR!/home/username/.npm/_logs/2018-04-15T09_19_49_453Z-debug.log any help? 回答1: your scripts of package.json should be: "scripts": { "start": "node ./examples/app.js", "test": "echo \"Error: no test specified\" && exit 1" } 回答2: It looks like there is no start command in scripts i.e in your package.json file. Below is the start

Rx scan(), cannot generate observable from seed and another observable

大兔子大兔子 提交于 2019-12-11 14:14:32
问题 I have a seed value Triangle (Bool) and an observable that emits values Circle (Int) . My intention is to generate a new observable (Triangle, Circle) each time a value is emitted from that observable, transforming the Triangle value negating the current value. This is my marble diagram: But I cannot achieve it, and I don't know if scan is the correct operator. This is my code: typealias Triangle = Bool typealias Circle = Int func scan() { let triangle: Triangle = false circleObservable .scan

Angular 2 - Using Observables in a component to emit values to other components

ぃ、小莉子 提交于 2019-12-11 13:56:36
问题 I am wondering if it is possible to use Observables in components, and which other components can subscribe to? BugListComponent - component is injected in the boot.ts file where I load all my services (where boostrap is located) import {Subject, BehaviorSubject} from 'rxjs/Rx'; viewBugList$: Subject<boolean>; constructor() { this.viewBugList$ = new BehaviorSubject<boolean>(false); } // Called from template, sends in 'true' private enableIEview(enable: boolean) { if(enable) { this.viewBugList

What's the difference between two Observables if one is created by defer?

走远了吗. 提交于 2019-12-11 13:17:59
问题 For instance, var interval = Rx.Observable.interval(1000); interval.subscribe(x => console.log(x)); And var deferred = Rx.Observable.defer(()=> return interval); deferred.subscribe(x=> console.log(x)); seem to do the same thing. It seems to that observables are by default "deferred". What is defer useful for? 回答1: defer takes a parameter function which returns an observable. The operator itself returns an observable, as most operators do. When that defer observable is subscribed to, it

Smarter buffers

情到浓时终转凉″ 提交于 2019-12-11 12:37:23
问题 I send request - get an array of data. In order to manipulate that data I need to flatten it, so I can use it as a stream of entities not stream of array of entities but, then on side-effect I want those entities appear in the UI at once, not one by one, so it updates UI only ones at a time. Let's say I have a code like this: // this generates a sequence of objects - getCasesStream sends an ajax request, // whenever dateRange changes casesStm = dateRangeStm.flatMapLatest(getCasesStream)

Akka stream map with retry

北城以北 提交于 2019-12-11 11:27:11
问题 How can i retry if mapping/processing of an element in the stream fails? I have tried setting the decider in materializer but it does not offer retry. It simply maps exception to Supervision stage. Thanks 回答1: Consider it as a tip rather than complete answer. I recently implement similar functionality with futures and mapAsync . There is a library called retry for retrying futures with different strategies such as pause or back off. But this method have a problem that because akka streams use

on assignment of reactiveValues() empty dataframe created

∥☆過路亽.° 提交于 2019-12-11 11:03:06
问题 Reproducable example: server.R library(shiny) shinyServer( function(input, output, session) { myDf <- reactiveValues(myData = NULL) problematicDf <- reactiveValues(test = NULL) observeEvent(input$myButton, { myDf$myData <- df }) observe({ output$myTestUi <- renderUI({ selectInput(inputId = 'mySelection', label = 'Selection', choices = levels(myDf$myData$z), multiple = T, selected = c(levels(myDf$myData$z)[1]) ) }) }) observe({ problematicDf$test <- subset(myDf$myData, ((myDf$myData$z %in%

Rx: What are subscriptions and how do subscriptions work?

霸气de小男生 提交于 2019-12-11 10:48:11
问题 I'm learning reactive extensions (rx) in .NET and I'm struggling a little bit with what a "subscription" really is and when it is used. Lets take some sample data, taken from this thread: using System; using System.Reactive.Linq; using System.Threading; namespace ConsoleApp1 { class Program { class Result { public bool Flag { get; set; } public string Text { get; set; } } static void Main(string[] args) { var source = Observable.Create<Result>(f => { Console.WriteLine("Start creating data!");

Safe update for 2 dependent streams

与世无争的帅哥 提交于 2019-12-11 10:16:55
问题 As an exercise I'm trying to build 2 dependent streams which update one another. The test application is simply an "Inches <-> Centimeters" converter, with both inputs editable. The issue I am experiencing is that I cannot get how can I stop recursion that causes one field change. To better explain the issue let's have a look at the relevant part of code: var cmValue = new Rx.BehaviorSubject(0), inValue = new Rx.BehaviorSubject(0); # handler #1 cmValue.distinctUntilChanged().subscribe

Issue with use of project reactor's flatMap and switchIfEmpty operators

最后都变了- 提交于 2019-12-11 07:37:18
问题 I have an issue with a reactive chain relying on flatMap() and switchIfEmpty() . For some reason, one of the Mono does not emit anything... This is the public handler method calling the others: //Throws: NoSuchElementException: Source was empty public Mono<ServerResponse> createUser(ServerRequest serverRequest) { Hooks.onOperatorDebug(); Mono<User> userMono = serverRequest.bodyToMono(User.class); return validateUser(userMono) .switchIfEmpty(saveUser(userMono)) .single(); } This is the first