1
msdsk
5y

I got to a point where I have a multi-level recursive promises within loops and my mental map is by far not enough to process this. I wish there were some visualisation tools for this - though I don't even know how it could look like. All I know is that at some point I'm returning a wrong promise and the recursion is not correctly handled.

Comments
  • 3
    Recursive promises?

    You are doing something wrong.
  • 0
    So you actually mean recursive Promise in the actual sense of recursive or just nested?
  • 0
    @don-rager

    @magicMirror

    recursive, unfortunately. Google API, I'm getting in a response a next page token; after that I need to wait a moment for the token to become valid (fun fact, the time length is not documented) and then I can resend the previous request, this time with the token to get the next page, repeating for as long as I am receiving a new token back, so it actually needs to call itself again.
  • 2
    Considering breaking token handling and resolution into a separate piece to reduce mental complexity and make them testable in isolation.

    The interceptor pattern is an excellent option for this sort of thing:
    https://en.m.wikipedia.org/wiki/...
  • 3
    @SortOfTested

    Thank you! I managed to simplify it a great deal by just cleaning up code, now I'm back to struggling with the library!
  • 1
    Yep. Feel ya, Google APIs are a source of massive pain on the reg ☺️
  • 0
    @SortOfTested

    I especially love their unhelpful error messages.
Add Comment