observable

Angular : Dynamically push data to observable without changing value in input

我与影子孤独终老i 提交于 2019-12-11 18:49:08
问题 I have used mat-autocomplete with Angular material 7. this.salesPickerAutoComplete$ = this.autoCompleteControl.valueChanges.pipe( startWith(''), debounceTime(400), distinctUntilChanged(), switchMap(value => { if (value && value.length > 2) { return this.getSalesReps(value); } else { return of(null); } }) ); getSalesReps(value: string): Observable<any[]> { const params = new QueryDto; params.$filter = `substringof('${value}',FirstName) or substringof('${value}',LastName)`; params.$select =

KnockoutJS and PubSub to update observable array between views

大城市里の小女人 提交于 2019-12-11 17:51:38
问题 I have two modalviews - MyModalViewA (parent) and MyModalViewB (child). MyModalViewA spawns MyModalViewB , as custom binding, as well has observable array which I need to update. And it looks like: (function () { 'use strict'; var window = __webpack_require__(/*! window */ 10), _ = __webpack_require__(/*! _ */ 2), $ = __webpack_require__(/*! $ */ 12), ko = __webpack_require__(/*! ko */ 3), key = __webpack_require__(/*! key */ 16), Enums = __webpack_require__(/*! Common/Enums */ 4), Utils = _

Observables: Creating a mock http request

点点圈 提交于 2019-12-11 17:45:06
问题 I'm trying to test my front-end code without the back-end api using observables. In my component's template I have a textarea. Ultimately I need to send the textarea content to back-end api using http.post and receive back the validation for the content. In the constructor of my component.ts I define an observable which does some very basic checks and creates mock results after a timeout of 2000ms (like http.post/http.get): private obsVal: Observable < any >; private obsChange: Observable <

Subscribing to Observable not triggering change detection

烈酒焚心 提交于 2019-12-11 17:03:27
问题 I am using 'angular2-virtual-scroll' to implement load on demand. The items used to be driven by observable's using the async pipe triggered by the parent component. Now i am trying to call my service from the child. The call is successful and i get my data, i need to use the subscribe event to apply other logic. The issue is change detected does not appear to be working when i update my arrays in the subscribe function. I have read other similar issues but i have had no luck finding a

Rxjs: Missing property error with lettable operators

丶灬走出姿态 提交于 2019-12-11 15:40:04
问题 I'm trying to use Lettable Operators in my import statement after upgrading to Angular 5.0.0 and I get this error. ERROR in src/app/components/hero-detail/hero-detail.component.ts(32,8): error TS2339: Property 'switchMap' does not exist on type 'Observable<ParamMap>'. I changing from import "rxjs/add/operator/switchMap" to import { switchMap } from "rxjs/operators" If fails on this code block: ngOnInit(): void { this.route.paramMap .switchMap((params: ParamMap) => this.heroService.getHero(

Knockout : Push value in ko observable array with dynamic key

五迷三道 提交于 2019-12-11 15:35:58
问题 I want to add push value in array with dynamic key. I use this below code : this.customOptionVal.push({name:value}); this.customOptionVal is ko.observableArray() Output of the above code is : 0: {name: "stack"} I want to get output like this : mykey: {name: "stack"} How to do this? 回答1: If you can use a simple observable and not an observableArray (because arrays will always use indices and not custom keys), you can set that customOptionVal is an observable object: customOptionVal = ko

Share data between components with Subject

僤鯓⒐⒋嵵緔 提交于 2019-12-11 15:15:40
问题 I am trying to share data between two components in Angular 6 with Subject. Somehow it does not work and I can not find out why. I need to pass data from compare.component to profile.component with click. When I click, data is not passed. But somehow when I go back and then click again, it works. What do I do wrong? data.service import {Subject} from 'rxjs'; export class DataService { data = new Subject(); } profile.component export class ProfileComponent implements OnInit { constructor

Filtering an observable in Angular/Nativescript

做~自己de王妃 提交于 2019-12-11 14:32:50
问题 Currently, I'm trying to build an app which retrieves an obserable, which you can then sort and/or filter in some predefined ways. Retrieving and sorting the data works fine: sort.service.ts import { Injectable } from "@angular/core" import { HttpClient, HttpErrorResponse } from "@angular/common/http" import { Observable } from "rxjs/Observable"; import { Subscriber } from "rxjs"; import "rxjs/add/operator/catch"; import "rxjs/add/operator/do"; import "rxjs/add/operator/map"; import {

Endless HTTP Stream Observable not emitting anything but data transferred

a 夏天 提交于 2019-12-11 14:32:20
问题 I've been digging an issue with Angular 4 and RxJS. Here is my code, the issue is, the http.post request Observable is not emitting anything to the next of the chain, the map() . The POST just get an endless response, it's a stream of Motion JPEG data. Now I have to deal with the data, say each 500KB transferred. My problem is that I cannot do anything with the data if the Observable not emitting anything. So how to make such angular HTTP feature emit to the next of the chain each chunk of

How to return Observable of type object from a method in the interface

[亡魂溺海] 提交于 2019-12-11 14:03:41
问题 I am learning kotlin. as shown in the code below, i created a object Model and an interface. the method in the interface should return Model.Result but when I wrap the aforementioned data type in Observable I receive the following error No type argument expected for class observable please let me know how fix this issue...as i tried to find some solution in google but it does not work Object : public object Model { data class Result(val query: Query) data class Query(val searchinfo: