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

Add Path #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add Path #6

wants to merge 7 commits into from

Conversation

Simon-U
Copy link

@Simon-U Simon-U commented Nov 16, 2024

Adding path argument to dash_socketio.

Enables to customise the path and route it to different server if needed.

@RenaudLN
Copy link
Owner

RenaudLN commented Nov 23, 2024

Thanks Simon, I removed all the auto-generated files from main and from your branch, if you can pull main into yours to get this updated that would be great.

Also rather than just passing path, I think it would be good to pass other io client options to the function if that's clear?

@Simon-U
Copy link
Author

Simon-U commented Nov 23, 2024

Yeah, you mean, for example, the reconnection parameter and others as well.

Yeah, I started that, but for me, it was more important to get the path going :D

I can make a new pull after this one and add the others.

@Simon-U
Copy link
Author

Simon-U commented Nov 23, 2024

It looks like the auto-generated files are removed. You pushed it already to mean. I see the commit in this PR as well.

@RenaudLN
Copy link
Owner

What I meant is rather than a path argument, I would like a client_options argument, to which you can pass path. It would be good that the options are typed as well.

@Simon-U
Copy link
Author

Simon-U commented Nov 23, 2024

Ah, I got it. I will change that. It makes it easy to add different options in the future.

@Simon-U
Copy link
Author

Simon-U commented Nov 24, 2024

Please check the last commit. I added some variables already to provide some more options.

Is that the way you intended it to be?

Copy link
Owner

@RenaudLN RenaudLN left a comment

Choose a reason for hiding this comment

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

Thanks looking good! A few minor comments

Comment on lines +34 to +38
const defaultOptions: SocketOptions = {
path: '/socket.io',
forceNew: false,
autoConnect: true
};
Copy link
Owner

Choose a reason for hiding this comment

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

Are these the default values if left blank? If so let's not pass anything.

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure if I completely understand. The defaultOptions set certain values for some of the variables.
Where some other props for the Socket, are not set by default.

What part do you want to remove?

Copy link
Owner

Choose a reason for hiding this comment

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

the path forceNew and autoConnect already default to these values when nothing is passed to io() so no need to explicitly set them

const socket = React.useMemo(() => io(
url || undefined, {auth: {pathname: window.location.pathname}}
), [url])
const { url, options = {}, setProps, eventNames } = props;
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not familiar with this syntax, will this make it an empty object only if it is null?

Copy link
Author

Choose a reason for hiding this comment

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

It will destructure the options object. The default value is {}. If we have options {'timeout': 300} then we get that. If options: null, we would get null.

}

DashSocketIO.defaultProps = {};
Copy link
Owner

Choose a reason for hiding this comment

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

Any reason this was deleted?

Copy link
Author

Choose a reason for hiding this comment

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

Not really. I defined default values with
const defaultOptions: SocketOptions = { path: '/socket.io', forceNew: false, autoConnect: true };

That's why I thought it might be not needed.

Copy link
Owner

Choose a reason for hiding this comment

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

I think Dash might be expecting this to exist, at least it was part of the template, I suggest rolling this back.

query?: Record<string, any>;
/** Authentication data */
auth?: Record<string, any>;
[key: string]: any;
Copy link
Owner

Choose a reason for hiding this comment

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

Let's not put this one for now.

Copy link
Author

Choose a reason for hiding this comment

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

The whole socket options block?

Copy link
Owner

Choose a reason for hiding this comment

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

No just the [key: string]: any part

@RenaudLN
Copy link
Owner

Sorry took me a while to get back to this, I answered your questions :)

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.

2 participants