observable

Handlebars template not respecting view member when set from render helper

喜你入骨 提交于 2019-12-25 02:19:56
问题 I have a form that can filled out on its own or embedded into another form, as part of a larger object. When I {{render}} the form from the containing handlebars template, the child template does not respect the observable on the view. Parent template: {{render "EditIntro" introModule embedded=true}} Where introModule is a property on the containers model which returns a the specific submodel for the intro, which is a part of the parent. Child View: App.EditIntroView = Ember.View.extend({

How to handle an empty result with rxjs observable

╄→гoц情女王★ 提交于 2019-12-25 01:02:34
问题 I have an API that might return [] result. HTTP/1.1 200 OK Date: Tue, 16 Apr 2018 06:06:22 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked Request-Context: appId=cid-v1:... [] Here is my code that just does not work in that particular case: getData(): Observable<Thing[]> { return this.getData1() .pipe( flatMap(aData => { const ids = aData.map(({ id }) => id); const bData = this.getBData(ids); // emty result might be here //test subscribe this

Diffing two Observables

我只是一个虾纸丫 提交于 2019-12-25 00:54:12
问题 I'm looking for a best way to Diff two Observables. Filtered values from ObservableA should be emited as soon as ObservableB completes without waiting for ObservableA to complete. <html> <head> <title></title> <script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.3.0/Rx.js"></script> <script> const observable_a = Rx.Observable.interval(2000).take(10);//0,1,2,3,4,5,6,7,8,9 const observable_b = Rx.Observable.interval(1000).map(x=>x+3).take(5);//3,4,5,6,7 someDiffObservable(observable_a

Observer pattern update parameters

爷,独闯天下 提交于 2019-12-25 00:07:15
问题 Why does the Observer interface has Observable o as a parameter? Do you recommend using Javas existing classes (implements Observer; extends Observable)? public class Test implements Observer { void update(Observable o, Object arg); } 回答1: It receives the Observable reference so that the Observer can use it to address the way it will handle the Object arg that was passed. Also, the Observer could call deleteObserver to remove itself once it finished the job. You shouldn't use them. And it's

RxJs move array of objects to root array

旧城冷巷雨未停 提交于 2019-12-24 23:06:38
问题 I am getting below set of data via Observable [ 0: {id: "12321", itemName: "Item 1", category: "All"}, 1: [ 0: {id: "423423", itemName: "Sub Item 1", category: "subcat"}, 1: {id: "413212", itemName: "Sub Item 2", category: "subcat"} ], 2: {id: "65655", itemName: "Item 2", category: "All"}, 3: {id: "87877", itemName: "Item 3", category: "All"}, 4: [ 0: {id: "354345", itemName: "Sub Item 1", category: "subcat"}, 1: {id: "123434", itemName: "Sub Item 2", category: "subcat"}, 2: {id: "765767",

How to make POST requests to save a list of objects in the hierarchical structure in angular

徘徊边缘 提交于 2019-12-24 22:49:58
问题 I have a list of objects in the hierarchical structure which are related by parentId, for example: [ { id: 10, name: "Parent Unit 1", parentId: null, children: [ { id: 11, name: "Unit Child 1.1", parentId: 10, children: [ { id: 15, name: "Unit Child 1.1.1", parentId: 11, children: [] ] }, { id: 12, name: "Unit Child 1.2", parentId: 10, children: [] } ] }, { id: 13, name: "Parent Unit 2", parentId: null, children: [ { id: 14, name: "Unit Child 2.2", parentId: 13, children: [] } ] ] I need to

How to keep your data in sync throughout your application?

拈花ヽ惹草 提交于 2019-12-24 21:34:31
问题 I have many components displaying single or multiple products provided by a service. getProducts() { return this.http.get('/api/products'); } getProduct(id) { return this.http.get('/api/product/'+id); } In some components, I can add new products or edit them using this service. saveProduct(product) { if(product._id) { return this.http.put('/api/product/'+product._id, product); } return this.http.post('/api/product', product); } These components are displayed simultaneously but not directly

Angular CanActivate With Login Dialog

陌路散爱 提交于 2019-12-24 20:32:32
问题 I have an AuthGuard in which I want to use a login material2 dialog with it. So before canActivate returns, the login dialog is shown and if the login is successful then the dialog returns true so then canActivate returns true as well. If the login is not successful, then the dialog does not return anything and tries again. I have already implemented the dialog in a component and its working fine, I'm looking for help on how to integrate it with the canActivate guard. @Injectable() export

Angular: Binding Component Input to Property of Value from Observable

坚强是说给别人听的谎言 提交于 2019-12-24 19:56:41
问题 In Angular 7, when the property of a value emitted by an Observable is bound to the input of a child component, is it expected that the input value gets updated (and ngOnChanges invoked) even when the bound property has not changed? Given the following observable that simply emits a new object with identical properties every second: const source$ = interval(1000).pipe(map(() => ({ prop: 'something' }))); this.obs$ = source$; Then bind a property of the emitted value to a child component:

Angular 6 - problem executing nested .subscribe() “next” function

南楼画角 提交于 2019-12-24 19:47:33
问题 I've created an app with user authentication system. Firstly I check if user with given registration e-mail exists and if does not - I call registration service. register.component.ts registerUser(email: String, password: String) { let found = false; this.authService.findUser(email).pipe( tap(res => { console.log(res.status); if (res.status === 202) { found = true; } else if (res.status === 200) { found = false; } else {found = null; }}), concatMap(res => { console.log(found); if (found) {