!DJCaZMEJBuQXnQdkPy:matrix.org

Angular

918 Members
Discussion for angular (2+) - need help? create a stackblitz with your issue to get help faster using this template: https://stackblitz.com/fork/angular-issue-repro229 Servers

Load older messages


SenderMessageTime
23 Oct 2020
@gitter_galarzaa90:matrix.orgAllan Galarza (Gitter)

So this is kinda my layout, I tried to replicate the structure with divs, just so you can see the the hierarchy, in reality, this is a material toolbar, with a material sidebar.

I have AuthGuards that take you out to the login page (which doesn't have the toolbar, hence why I'm using child components

So the user first sees a list of their servers, and once they choose a server, they see its overview, and they should see the sidebar with the menu. I'm trying to make the links in the sidevar be relative to the current route, e.g servers/2/events but I don't know how I would access to those parameters, because the url ends up as /events instead.

https://stackblitz.com/edit/sidebar-links?file=src%2Fapp%2Fcomponents%2Fnavbar.component.ts

02:46:10
@gitter_galarzaa90:matrix.orgAllan Galarza (Gitter) (edited) ... child components So ... => ... child components) So ... 02:46:16
@gitter_galarzaa90:matrix.orgAllan Galarza (Gitter) (edited) ... instead. https://stackblitz.com/edit/sidebar-links?file=src%2Fapp%2Fcomponents%2Fnavbar.component.ts => ... instead. https://sidebar-links.stackblitz.io/servers 02:46:56
@gitter_galarzaa90:matrix.orgAllan Galarza (Gitter) (edited) ... instead. https://sidebar-links.stackblitz.io/servers => ... instead. https://stackblitz.com/edit/sidebar-links?file=src/app/components/navbar.component.ts 02:47:18
@gitter_galarzaa90:matrix.orgAllan Galarza (Gitter) (edited) ... instead. https://stackblitz.com/edit/sidebar-links?file=src/app/components/navbar.component.ts => ... instead. https://stackblitz.com/edit/sidebar-links?file=src/app/components/navbar.component.ts Maybe my whole problem is that I shouldn't be using that layout structure? 02:48:03
@gitter_shekharramola:matrix.orgShekhar Ramola (Gitter)I have a situation in which I have an array of object which I can pass on the routes but is not seo friendly.. is there any workaround for this situation?06:34:43
@gitter_shekharramola:matrix.orgShekhar Ramola (Gitter)can i build query params inside a loop to make it more readable by passing only key06:41:11
@gitter_shekharramola:matrix.orgShekhar Ramola (Gitter)how to see what is being passed in decoded form in route?07:19:02
@gitter_shekharramola:matrix.orgShekhar Ramola (Gitter) 07:19:07
@gitter_kenan7:matrix.orgMirkenan Kazımzade (Gitter)

why does angular make such requests twice? sometimes my 3rd party API requests fail because of that (max retries exceeded) (exchange API)

anyways, I did write take(1) in pipe() but still, something is wrong. can someone explain that to me, please?

07:26:32
@gitter_haneatic:matrix.orghaneatic (Gitter)I would like to filter the results of one observable based on an value of another observable. My approach would be to put both into a combineLatest and pipe it into a switchMap, is that correct?08:09:57
@gitter_haneatic:matrix.orghaneatic (Gitter) if I do that, apply my filters and return the object insid the switchMap it is complaining that the return value needs to be of type ObservableInput<any> 08:15:45
@gitter_haneatic:matrix.orghaneatic (Gitter)...i dont get it08:15:49
@gitter_haneatic:matrix.orghaneatic (Gitter)for example08:15:58
@gitter_haneatic:matrix.orghaneatic (Gitter)
combineLatest([this.currentStatus$, this.currentProduct$]).pipe(switchMap(({status, product}) => {
  product.status = status;
  return product;
}))
08:16:54
@gitter_haneatic:matrix.orghaneatic (Gitter)isnt that allowed? lol08:17:14
@gitter_haneatic:matrix.orghaneatic (Gitter)vscode suggests me to add an async in front of the switchMap, wtf?08:33:23
@gitter_haneatic:matrix.orghaneatic (Gitter) @Kenan7 you are probably subscribing to the observable multiple times 08:38:18
@gitter_kenan7:matrix.orgMirkenan Kazımzade (Gitter) @haneatic yeah.. I don't know that. what do you mean? I tried to make it sub 1 one time with take(1) but not workin 08:41:27
@gitter_kenan7:matrix.orgMirkenan Kazımzade (Gitter) (edited) ... not workin => ... not working 08:41:32
@gitter_haneatic:matrix.orghaneatic (Gitter) @Kenan7 well the http client returns a cold observable which means that it only produces a value if you subscribe to it somewhere 08:46:08
@gitter_haneatic:matrix.orghaneatic (Gitter)moreover, for each subscription it repeats the request08:46:19
@gitter_haneatic:matrix.orghaneatic (Gitter)take(1) results in your subscription only taking one value out of the stream08:46:49
@gitter_haneatic:matrix.orghaneatic (Gitter)but well, if you susbcribe multiple times that does not fix your issue08:46:58
@gitter_haneatic:matrix.orghaneatic (Gitter)The documentation on rxjs does not explicitly state that you have to make sure that your return value is an observable08:53:14
@gitter_haneatic:matrix.orghaneatic (Gitter)I have to wrap my product in an of() so the type error goes away08:53:25
@gitter_haneatic:matrix.orghaneatic (Gitter)I dont get it :^)08:53:27
@gitter_haneatic:matrix.orghaneatic (Gitter)wait is it because the switchMap takes in an array due to the usage of combineLatest so it has to return an array as well? 08:54:45
@gitter_haneatic:matrix.orghaneatic (Gitter)
combineLatest([this.currentStatus$, this.currentProduct$]).pipe(switchMap(({status, product}) => {
  product.status = status;
  return [product];
}))
Also works. What if I dont wanna return an array but an object instead?
08:57:21
@gitter_haneatic:matrix.orghaneatic (Gitter)alternatively I can specify a return type in front of the switchMap but that all seems kinda hacky09:12:46

There are no newer messages yet.


Back to Room List