Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.listen() callback? #4

Open
eladcandroid opened this issue Jul 10, 2022 · 5 comments
Open

app.listen() callback? #4

eladcandroid opened this issue Jul 10, 2022 · 5 comments

Comments

@eladcandroid
Copy link

Do we have such a thing?

@fdemir
Copy link

fdemir commented Jul 10, 2022

I've seen this thing before. I would like to contribute.

@mattreid1
Copy link
Owner

Do we have such a thing?

I'm unsure if this is needed, once app.listen() is executed, it will return a Server object and the code below it will continue to execute, e.g.

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

I might be wrong though - let me know if I've missed something!

@wobsoriano
Copy link

Adding a callback like feature would be easy as this:

class Bao {
  listen(options: IListen = {}, cb?: () => void): Server {
    const server = Bun.serve(this.#serve(options));
  
    cb?.()
  
    return server
  }
}

@fdemir
Copy link

fdemir commented Jul 14, 2022

Adding a callback like feature would be easy as this:

class Bao {

  listen(options: IListen = {}, cb?: () => void): Server {

    const server = Bun.serve(this.#serve(options));

  

    cb?.()

  

    return server

  }

}

we can merge my pr actually for this.

@wobsoriano
Copy link

@fdemir Oh I did not notice 😅 awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants