Bijoujs / Bijou.js

Bijou.js: Useful JavaScript snippets in one simple library
https://bijou.js.org
GNU General Public License v3.0
32 stars 8 forks source link

[Feature request] Use promises rather than callbacks for some functions #80

Closed pufferfish101007 closed 3 years ago

pufferfish101007 commented 3 years ago

Is your feature request related to a problem? Please describe. I'm always frustrated when [I find myself having to use callbacks for something that I need to wait some time for, such as _$.loadScript, and other functions that rely on that. I often find myself in callback hell, rather than promise paradise.

Describe the solution you'd like It would be great if these functions could return a promise rather than running a callback.

Describe alternatives you've considered Alternatively, it could use a system whereby you may pass a callback as a param, in which case it would run the callback, and if it was not present it would return a promise. However, I don't think this is necessary, as all programmers should really use asynchronous functions using promises nowadays.

Additional context n/a

github-actions[bot] commented 3 years ago

Hi there! Welcome to Bijou.js! We appreciate you contributing to this project! Someone will look over your issue shortly! In the meantime you can take a look at our website to learn more about this project! This message is automated

Explosion-Scratch commented 3 years ago

I want to keep the functionality currently but a lot of those functions return undefined, so there is no point not returning a promise.

pufferfish101007 commented 3 years ago

Thanks, I like the way you've done it, but event-listener-type functions shouldn't use promises, as promises can only be resolved once.