reactive-programming

tap() isn't triggered in RXJS Pipe

只谈情不闲聊 提交于 2019-11-27 07:47:14
问题 I have to ways of doing the same thing, although I prefer the first one. But the first approach doesn't seem to work. (the tap() is not triggered) // does not work this.actions$.pipe( ofType(LayoutActions.Types.CHANGE_THEME), takeUntil(this.destroyed$), tap(() => { console.log('test') }), ); // works this.actions$.ofType(LayoutActions.Types.CHANGE_THEME).subscribe(() => { console.log('test') }); 回答1: Imagine RxJS pipes like actual, physical pipes with a valve at the end. Each pipe will

Rx.js wait for callback to complete

痞子三分冷 提交于 2019-11-27 07:31:29
问题 I am using Rx.js to process the contents of a file, make an http request for each line and then aggregate the results. However the source file contains thousands of lines and I am overloading the remote http api that I am performing the http request to. I need to make sure that I wait for the existing http request to callback before starting another one. I'd be open to batching and performing n requests at a time but for this script performing the requests in serial is sufficient. I have the

How to get Sum of “last” items of N hot Observable<decimal> instances?

混江龙づ霸主 提交于 2019-11-27 06:54:39
问题 EDIT: On 09/15/2013 - I am describing my scenario further broken into steps to help everybody understand my situation better. Added the source for whole application for download too. If you want to jump to the original question, scroll down to the last heading. Please let me know the questions. Thanks Summary Alaska state Capital Juneau has a AST (Alaska State Trooper) headquarters building where they would like to show a large screen with a single number displayed and updated automatically.

How to use exhaustMap in ReactiveX/rxjs 5 in TypeScript

杀马特。学长 韩版系。学妹 提交于 2019-11-27 06:15:28
问题 I was wondering how can I process an array where each value returns a Promise in the same order as they're specified. For example, let's say I want to call multiple Ajax calls in this order: var array = [ 'http://example.org', 'http://otherexample.org', 'http://anotherexample.org', ]; There's basicaly the same question: How can I use RxJs to hold off any requests for an AJAX call until the previous one resolves, which suggests using flatMapFirst . Since I'm using Angular2 ( beta-15 at this

RxJava Fetching Observables In Parallel

馋奶兔 提交于 2019-11-27 06:03:08
I need some help in implementing parallel asynchronous calls in RxJava. I have picked up a simple use case wherein the FIRST call fetches (rather searches) a list of products (Tile) to be displayed. The subsequent calls go out and fetch (A) REVIEWS and (B) PRODUCT IMAGES After several attempts I got to this place. 1 Observable<Tile> searchTile = searchServiceClient.getSearchResults(searchTerm); 2 List<Tile> allTiles = new ArrayList<Tile>(); 3 ClientResponse response = new ClientResponse(); 4 searchTile.parallel(oTile -> { 5 return oTile.flatMap(t -> { 6 Observable<Reviews> reviews =

Howto call back async function from rx subscribe?

隐身守侯 提交于 2019-11-27 05:29:36
问题 I would like to call back an async function within an Rx subscription. E.g. like that: public class Consumer { private readonly Service _service = new Service(); public ReplaySubject<string> Results = new ReplaySubject<string>(); public void Trigger() { Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(async _ => await RunAsync()); } public Task RunAsync() { return _service.DoAsync(); } } public class Service { public async Task<string> DoAsync() { return await Task.Run(() => Do());

How to create an Observable from OnClick Event Android?

好久不见. 提交于 2019-11-27 05:11:38
问题 I'm new in reactive programming. So I have problem when create a stream from an Event, like onClick, ontouch... Can anyone help me solve this problem. Thanks. 回答1: You would do something like this: Observable<View> clickEventObservable = Observable.create(new Observable.OnSubscribe<View>() { @Override public void call(final Subscriber<? super View> subscriber) { viewIWantToMonitorForClickEvents.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if

What's the status of current Functional Reactive Programming implementations?

让人想犯罪 __ 提交于 2019-11-27 04:58:04
问题 I'm trying to visualize some simple automatic physical systems (such things as pendulum, robot arms,etc.) in Haskell. Often those systems can be described by equations like df/dt = c*f(t) + u(t) where u(t) represents some kind of 'intelligent control'. Those systems look to fit very nicely in the Functional Reactive Programming paradigm. So I grabbed the book "The Haskell School of Expression" by Paul Hudak, and found that the domain specific language "FAL" (for Functional Animation Language)

RxJS takeWhile but include the last value

笑着哭i 提交于 2019-11-27 03:11:02
问题 I have a RxJS5 pipeline looks like this Rx.Observable.from([2, 3, 4, 5, 6]) .takeWhile((v) => { v !== 4 }) I want to keep the subscription until I see 4, but I want to last element 4 also to be included in the result. So the example above should be 2, 3, 4 However, according to official document, takeWhile operator is not inclusive. Which means when it encounters the element which doesn't match predicate we gave, it completes the stream immediately without the last element. As a result, the

Importing lettable RxJS operators

喜你入骨 提交于 2019-11-27 02:58:53
问题 RxJS 5.5 makes a big breaking change and introduces lettable operators to replace basically all operators (called "patch" operators) we used to use before. That article contains a note: Lettable operators can now be imported from rxjs/operators, but doing so without changing your build process will often result in a larger application bundle. This is because by default rxjs/operators will resolve to the CommonJS output of rxjs. This statement is easy to proof on the practice with the brand