observable

Property '_body' does not exist on type 'Response'

a 夏天 提交于 2019-12-17 15:53:56
问题 I am using Angular 2 and getting this error when using an observable Property '_body' does not exist on type 'Response' . The code is below this.securitiesService.getMarketMovers() .subscribe(data => { console.log(JSON.parse(data._body)) }); The getMarketMovers function is simply this: getMarketMovers() { return this._http.get('...url address...') } I have tried to set data to type any but that isn't working for me. The code works and there is definitely a _body property on data but it still

Merging http observables using forkjoin

荒凉一梦 提交于 2019-12-17 15:36:21
问题 I'm trying to avoid nested observables by using forkjoin . The current (nested) version looks like this: this.http.get('https://testdb1.firebaseio.com/.json').map(res => res.json()).subscribe(data_changes => { this.http.get('https://testdb2.firebaseio.com/.json').map(res => res.json()).subscribe(data_all => { /* Do this once resolved */ this.platform.ready().then(() => { this.storage.set('data_changes', data_changes); this.storage.set('data_all', data_all); document.getElementById("chart")

LiveData update on object field change

扶醉桌前 提交于 2019-12-17 15:24:53
问题 I'm using Android MVVM architecture with LiveData. I have an object like this public class User { private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } And my view model looks like this public class InfoViewModel extends AndroidViewModel {

Paginate Observable results without recursion - RxJava

回眸只為那壹抹淺笑 提交于 2019-12-17 09:52:35
问题 I've got a pretty standard API pagination problem which you can handle with some simple recursion. Here's a fabricated example: public Observable<List<Result>> scan() { return scanPage(Optional.empty(), ImmutableList.of()); } private Observable<?> scanPage(Optional<KEY> startKey, List<Result> results) { return this.scanner.scan(startKey, LIMIT) .flatMap(page -> { if (!page.getLastKey().isPresent()) { return Observable.just(results); } return scanPage(page.getLastKey(), ImmutableList.<Result

Difference between .unsubscribe to .take(1)

こ雲淡風輕ζ 提交于 2019-12-17 08:52:27
问题 I wonder, if there is any difference in performance between using .take(1) and .unsubscribe when unsubscribe is used right after the subscription: var observable = Rx.Observable.interval(100); First: var subscription = observable.subscribe(function(value) { console.log(value); }).unsubscribe(); Second: var subscription = observable.take(1).subscribe(function(value) { console.log(value); }); Any ideas of it makes any different regard the performance? 回答1: Each serves a different purpose so it

RxJs Observables nested subscriptions?

六月ゝ 毕业季﹏ 提交于 2019-12-17 06:45:14
问题 Whats the way to simplify something like the following code example? I can't find the right operator.. could anyone give a short example? this.returnsObservable1(...) .subscribe( success => { this.returnsObservable2(...) .subscribe( success => { this.returnsObservable3(...) .subscribe( success => { ... }, 回答1: As mentioned in comments, you are looking for the flatMap operator. You can find more details in previous answers : How to do the chain sequence in rxjs Why do we need to use flatMap?

RxJs Observables nested subscriptions?

佐手、 提交于 2019-12-17 06:45:10
问题 Whats the way to simplify something like the following code example? I can't find the right operator.. could anyone give a short example? this.returnsObservable1(...) .subscribe( success => { this.returnsObservable2(...) .subscribe( success => { this.returnsObservable3(...) .subscribe( success => { ... }, 回答1: As mentioned in comments, you are looking for the flatMap operator. You can find more details in previous answers : How to do the chain sequence in rxjs Why do we need to use flatMap?

Angular 2 cache observable http result data [duplicate]

无人久伴 提交于 2019-12-17 05:55:32
问题 This question already has answers here : What is the correct way to share the result of an Angular Http network call in RxJs 5? (22 answers) Closed last year . I have a service that fetches data via the HTTP service and returns an observable object. After the first call I would like to cache the result internally in the service, and once a new component will try to get the data it will take it from the cached result. Is there a simple solution for this? 回答1: If you lean into observables as a

KeyPress on input not worked

半腔热情 提交于 2019-12-14 03:58:25
问题 I need create keyPress (enter) binding for input. <div id="body"> <input type="text" data-value-update="keyup" data-bind="value: text, keyPress: onKeyPress"/> <div id="output"></div> </div> js: kendo.data.binders.widget.keyPress = kendo.data.Binder.extend({ init: function (element, bindings, options) { kendo.data.Binder.fn.init.call(this, element, bindings, options); var binding = this.bindings.keyPress; $(element.input).bind("keypress", function (e) { if (e.which == 13) { binding.get(); } })

Bind observable dictionary to listbox items. [WPF-C#]

99封情书 提交于 2019-12-14 02:17:51
问题 I try bind observable dictionary to listbox item, and my problem is. If I use normal generic dictionary, it works good. But if I use observable dictionary, listbox items are not loaded. Here is observable dictionary class: public class MyObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, INotifyCollectionChanged, INotifyPropertyChanged { private readonly IDictionary<TKey, TValue> _dictionary = new Dictionary<TKey, TValue>(); #region Implementation of INotifyCollectionChanged