JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
C4d
Sep 12, 2022 09:44
Resolved it by using catchError and just returning this.intercept(req, next). Sometimes one thinks too complicated...
C4d
Sep 12, 2022 07:15
Like a retry of the exact same request, which is not helping me....
C4d
Sep 12, 2022 07:13
Hi everyone. I'm trying to understand interceptors with angular. I'm setting headers in the interceptor, then returning next.handle with a retryWhen function.

This retryWhen checks for 401 error, asks the backend for a new token and then (here comes my problem) retries the request, WHICH I thought would trigger the interceptor again, to set the headers again (with the new token).

But somehow the interceptor is not executed when coming out of retryWhen. Is this expected?
C4d
Aug 16, 2022 08:40
Well........... the pipe isnt subscribing automatically to the event isnt it? -.-**********
C4d
Aug 16, 2022 08:32
Hey guys. I'm having brainfucks....
´´fromEvent(this.elRef.nativeElement, "scroll").pipe(tap(() => console.log("test")));´´ not working.
´´fromEvent(this.elRef.nativeElement, "scroll").subscribe(() => console.log("test"))´´ is working.

Why doesnt the first one fire?
C4d
Mar 9, 2022 14:43
Hey guys. Anyone used to work with google auth on a web-page? If I'm saving additional data to my own database, where is the connection between the data and the google user? The token will pretty sure change over time. Should I associate it just with the users email?
C4d
Feb 5, 2021 10:36
Could it be that detection only takes place on initial build but not rebuilds?
C4d
Feb 5, 2021 10:35
Already did CTRL+P and >Restart TSLint Server
C4d
Feb 5, 2021 10:35
On a fresh ng serve I get 6 files with CommonJS warnings. Looks like no matter which file I save to trigger a rebuild, they always disappear.
C4d
Feb 5, 2021 10:31
Good question. Have to observe it.
C4d
Feb 5, 2021 10:30
I mean.. without changes obviously. Project is running. I save a unchanged file, warnings disappear O.o.
C4d
Feb 5, 2021 10:30
Hi guys. My Angular10 project is complaining about dependencies to CommonJS. I know what this is about BUT: When rebuilding the warnings disappear and appear randomly. Any idea why?
C4d
Jan 18, 2021 15:51
(Angular 11) Is it bad practice to provide a result-callback from a service that asks the user for input (popup)? Should I rather go with a rxjs/observable/subject way?
C4d
Jan 18, 2021 08:24
Nvm -.- monday getting nice.
C4d
Jan 18, 2021 08:23
Uff................... that typo in ngfor......................................
C4d
Jan 18, 2021 08:20
(Angular ^11) Hi guys. I have a component in a component. The child has a *ngFor loop which causes a `Can't bind to ngforOf since it isn't a known property of 'child-component'`. Does it come from nesting components? Do the parent has to be a module?

I have added the BrowserModule to the app.module.ts (Imports) and the CommonModule to the module of the parents-parent (also Imports).
C4d
Jul 22, 2020 13:27
@Lapys you could navigate to about:blank and press F12.
C4d
Jul 22, 2020 13:26
@Lapys Devtools always run in the context of a website. What do you mean by opening without having a website?
C4d
Jul 22, 2020 12:31
@BenFortune @RichieBendall For-loop and Object.assign them?
C4d
Jul 22, 2020 10:48
Im just to dumb for rxjs. Check.
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
C4d
Nov 11, 2020 15:00
Thats a very creative pick! :D
C4d
Nov 11, 2020 14:59
Just wanted to ask for a link.
C4d
Nov 11, 2020 14:40
And mouse control to drag items.
C4d
Nov 11, 2020 14:39
Not my game... so I already started with image and grid detection on screen.
C4d
Nov 11, 2020 14:39
Well, in fact this is going to be an inventory sorter for a game.
C4d
Nov 11, 2020 14:38
@Arne Just thought the same :D.
C4d
Nov 11, 2020 14:37
But that will be it. I think everything further is too much work.
C4d
Nov 11, 2020 14:37
If space next to it never gets filled completely, test all remaining against each other for combination of remaining space. Not that hard until here.
C4d
Nov 11, 2020 14:36
After the first piece, check all remaining to fit next to it. After that, put the next biggest below the first and repeat.
C4d
Nov 11, 2020 14:35
Thought about something very similar.
C4d
Nov 11, 2020 14:29
Every big first, then fill small spaces where possible. Everything else goes manually.
C4d
Nov 11, 2020 14:28
Not trying to apply rocket-science.
C4d
Nov 11, 2020 14:28
Maybe I'm just going with a close enough approach.
C4d
Nov 11, 2020 14:27
Hahaha
C4d
Nov 11, 2020 14:26
Wanted to get rid of the monkey work.
C4d
Nov 11, 2020 14:26
Yeeeeeeeeah..... but I wanted a coded solution because I have to repeat it every now and then.
C4d
Nov 11, 2020 14:25
@AndrasDeak What do you mean?
C4d
Nov 11, 2020 14:24
Maybe I should just eat sweats and shutdown my computer.
C4d
Nov 11, 2020 14:23
Yeah lol
C4d
Nov 11, 2020 14:22
So there's coming in 2x1, 3x1, 3x2, 1x1 with some few big ones like 6x3 or 8x2.
C4d
Nov 11, 2020 14:22
Yeah.... its rather 15x40 big. With items mid size of 2x2.
C4d
Nov 11, 2020 14:20
I see. The struggle is real with that.
C4d
Nov 11, 2020 14:20
:D
C4d
Nov 11, 2020 14:19
Uff.... was afraid to hear that.
C4d
Nov 11, 2020 14:19
They are rectangles.
C4d
Nov 11, 2020 14:18
They are everything from 1x1 up to, dont know, maybe 5x5.
C4d
Nov 11, 2020 14:17
Items cant be rotated.
C4d
Nov 11, 2020 14:17
Oh. Its 2 dimensional.
C4d
Nov 11, 2020 14:17
(Before trying to code it for hours - better try to look up if someone did already ^^)
C4d
Nov 11, 2020 14:16
Hey everyone. I'm trying to fit items with different sizes into a limited space. Question is if they all together fit at all, and if yes, how they have to be aligned. Does any of you know an already existing algorithm for that? Does this type of sorting has a name?