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

docs: fix conjunction with fastify example #5057

Closed
wants to merge 1 commit into from

Conversation

KartikeSingh
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

Right now the readme example directly uses app.io in the conjunction with fastify example but io is undefined while the server (app) is not ready

const app = require('fastify')();
app.register(require('fastify-socket.io'));
app.io.on('connection', () => { /* … */ }); // here io is undefined
app.listen(3000);

New behavior

Now app.io is accessed after the server (app) is ready so it is defined

const app = require('fastify')();
app.register(require('fastify-socket.io'));
app.ready().then(() => {
    app.io.on('connection', () => { /* … */ }); // here app.io is defined
});
app.listen(3000);

Other information (e.g. related issues)

I was using it for the first time and got confused if I installed something wrong, then after diving into the detailed docs I understood what I was doing wrong.
Couldn't find this issue on my first few google searches, so fixing the readme should save a lot of trouble for other fastify users

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aa

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aa

@Ahmadiiq8 what does that mean? I think you should explain that as it is very ambiguous

darrachequesne pushed a commit that referenced this pull request Jul 22, 2024
@darrachequesne
Copy link
Member

Merged as b79d80a.

@KartikeSingh thanks a lot 👍

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

Successfully merging this pull request may close these issues.

4 participants