Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@arwTheDev the website is under development but the built in features fully functional - and it's theoretical public
-
greg-6236yWhy do you use a variable to store a value before you return it? Just return the value!
-
@greg- I needed it before I created the syncRequest function. It's from a forgotten past of myself 😥
-
catadoxa4166yThe calls for 'var array' and var data' are repeated in each function. I would refactor and turn that into it's own function, looks like it just needs two parameters. I think you'll find it even prettier that way.
-
I dunno. Writing code is like maintaining your own house while fixing up other people's houses for a living. You just don't get time to fix everything you want to.
Perfect code takes time. And if its a once off project it's okay as it is. -
@hexc the code is still unfinished ^^ (after that picture I worked about 2 hours on that follow system) it's just beautiful if you know my other JS classes ^^
-
@PrivateGER I know but I need to figure out how to make sth like a callback function.. :/ dunno how jet. Because my website loads posts one after another async calls will return mixed posts
-
@PrivateGER the problem is: I need to load posts in synchronized order, but I don't know how to do it with async requests.. :/ I read about promises and all that stuff but I don't think I understand it. I have my post loader sit in an for loop and if I use async calls the posts come in at random positions
-
@PrivateGER Then I have a problem with my for loop... But I have another idea I will try later ^^
-
greg-6236yJust load all yours posts in a single request, the requests hold return an array of post!
-
@greg- That is an extremely bad idea that will suck up tons of bandwidth and defeat the purpose of asynchronous loading.
-
greg-6236y@PrivateGER what's the worst, loading all the posts in a single async request or loading each post in a different sync request?
-
@PrivateGER @greg- did it asynchronous now... Did googled for about ever and find a solution suitable. Got everything covered asynchronous now ^^ still not pretty but getting there
-
@PrivateGER I want to mention that the website is currently hosted on my local server with Cloud-Flare protection. So Jeah, I try to keep my bandwidth use to a minimum ^^
-
@greg- Different requests are better. If your only requests fails, you lost.
Also, multiple allow for fetching many things at the same time. -
hexc11196yCouldn't all this be solved with a simple Promise.all ? This basically lets you wait till all promises finish before running the .than code
-
@hexc Didnt worked for me, tried it, nothing happend :/ but I got it to work with my solution above :)
Related Rants
While developing my meme website I think my newest js-file is oddly satisfying to look at ❤️
rant
js
ajax
meme