reactive-programming

RX - rethrow an error in containing method

泄露秘密 提交于 2021-02-20 10:31:43
问题 I need to translate an error in an RX stream ( IObservable ) into an exception in the method that contains the subscription to the stream (because of this issue https://github.com/aspnet/SignalR/pull/1331 , Whereby errors arent serialised to clients.) Once this issue is fixed I will revert to handling error properly e.g. I have the following method public IObservable<StreamItem> LiveStream() { _mySvc.Start(); return _mySvc.ThingChanged(); } So I have tried to subscribe to the stream and

How to use RxJS, MySQL and NodeJS

北城以北 提交于 2021-02-19 05:34:17
问题 I need a with RxJS for MySQL in NodeJS. Could someone give me an example for one select? On front-end I will use Angular2. 回答1: In my case, I'm using the MySQL npm package in a desktop application made with Electron and Angular. However the same should work even on a plain NodeJS application by installing and importing rxjs. I've first installed mysql and @types/mysql package with: npm install --saved-dev mysql @types/mysql Then I've created a MySQL service: import { Injectable } from '

RxJava: combine two optional observables

烈酒焚心 提交于 2021-02-19 04:09:14
问题 I have two Observable s, let's call them PeanutButter and Jelly . I'd like to combine them to a Sandwich Observable . I can do that using: Observable<PeanutButter> peanutButterObservable = ...; Observable<Jelly> jellyObservable = ...; Observable<Sandwich> sandwichObservable = Observable.combineLatest( peanutButterObservable, jellyObservable, (pb, j) -> makeSandwich(pb, j)) The problem is that RX waits for the first PeanutButter and the first Jelly to be emitted before emitting the first

RxJava: combine two optional observables

守給你的承諾、 提交于 2021-02-19 04:08:20
问题 I have two Observable s, let's call them PeanutButter and Jelly . I'd like to combine them to a Sandwich Observable . I can do that using: Observable<PeanutButter> peanutButterObservable = ...; Observable<Jelly> jellyObservable = ...; Observable<Sandwich> sandwichObservable = Observable.combineLatest( peanutButterObservable, jellyObservable, (pb, j) -> makeSandwich(pb, j)) The problem is that RX waits for the first PeanutButter and the first Jelly to be emitted before emitting the first

rxjs: perform some action regulary with specific delay in between

北战南征 提交于 2021-02-18 21:10:49
问题 Client applications sends request to server, that could potentially take long to complete. Once request is finished or failed, client should wait some period of time (i.e. 10 seconds) and then again send the request. Current working solution is this: appRequest = new Subject(); ngOnInit(): void { this.appRequest.delay(10000).subscribe(() => this.refresh()); this.refresh(); } refresh() { this.api.getApplications().subscribe(a => { this.updateApplications(a); this.appRequest.next(); },() =>

Hide and Show View With Animation in React Native v0.46.

无人久伴 提交于 2021-02-18 17:00:57
问题 Friends, I have issue to hide and show view in react native. I have do the folloing code. Want to hide and show view with animation. Please help me. Code : import React, { Component } from "react"; import { AppRegistry, Image, View, Text, Button, StyleSheet, TouchableHighlight, } from "react-native"; import { StackNavigator } from "react-navigation"; import SignUpScreen from "./SignUp"; import AddManagerScreen from "./AddManager"; class SplashScreen extends Component { constructor(props) {

Merge two observables, single output

好久不见. 提交于 2021-02-18 09:02:01
问题 Hello guys Im trying to grasp RxJS lib and the whole idea of reactive programming. Im trying to merge two observables into one. First observable contains array of objects DefectImages[] the second observable contains array of strings, which then I convert to array of DefectImages[] . After that I would like to merge these two observables into one. Below my code: const observable = CachedPhotosBuffer.getInstance().asObservable() .pipe( switchMap(data => { return data.map((url) => DefectImage

Merge two observables, single output

妖精的绣舞 提交于 2021-02-18 09:01:41
问题 Hello guys Im trying to grasp RxJS lib and the whole idea of reactive programming. Im trying to merge two observables into one. First observable contains array of objects DefectImages[] the second observable contains array of strings, which then I convert to array of DefectImages[] . After that I would like to merge these two observables into one. Below my code: const observable = CachedPhotosBuffer.getInstance().asObservable() .pipe( switchMap(data => { return data.map((url) => DefectImage

API polling and timeout

非 Y 不嫁゛ 提交于 2021-02-11 08:52:06
问题 I have a polling use-case where: I want to call an API that, based on business logic, returns numbers(1-10) or error (network issue/ exception in API etc..) instantly (1.5-2 sec). If the API returns an error (network issue/ exception in API etc..) then I want to unsubscribe the polling and display error. If the API returns success, I want to check the return value and un-subscribe(if the return value is 5) or keep the polling going. I want to call API every 5 sec. I want to keep the max time

Binding methods in react components

[亡魂溺海] 提交于 2021-02-11 04:57:20
问题 I'm getting an error when I try to bind values to the component function handleInput: Uncaught TypeError: Cannot read property 'bind' of undefined However, when I insert the input element into the return statement at the bottom of the render method, it doesn't produce any errors. I'm guessing that this has something to do with the lifecycle of the render method, but I'm not sure. Any insight is appreciated. As for what the code does, it retrieves a string from this.props.info.text and