baojs icon indicating copy to clipboard operation
baojs copied to clipboard

:sparkles: add listen callback function

Open fdemir opened this issue 3 years ago • 4 comments

i didn't write some tests since we have no proper test integration. but it can be able to merge now.

fdemir avatar Jul 10 '22 23:07 fdemir

closes #4

fdemir avatar Jul 10 '22 23:07 fdemir

@mattreid1 Is it good enough to be merged?

eladcandroid avatar Jul 28 '22 07:07 eladcandroid

I don't have any issue with the code itself, but I struggle to see why it's needed?

As mentioned in #4, app.listen() does not block further code execution and returns the server object. Any code that would be in a callback can just be run after it (see below).

const server = app.listen();
console.log(server.hostname); // http://0.0.0.0:3000/

if (someCondition === true) server.stop();

If I'm missing something let me know!

mattreid1 avatar Aug 08 '22 11:08 mattreid1

I don't have any issue with the code itself, but I struggle to see why it's needed?

As mentioned in #4, app.listen() does not block further code execution and returns the server object. Any code that would be in a callback can just be run after it (see below).

const server = app.listen();
console.log(server.hostname); // http://0.0.0.0:3000/

if (someCondition === true) server.stop();

If I'm missing something let me know!

i agree with you definitely. i think this feature should exist as optional because of the developer experience which most of people get used to.

fdemir avatar Aug 08 '22 11:08 fdemir