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

1.0.0 Replacements for socket.set() and socket.get() #1481

Closed
doughsay opened this issue Apr 1, 2014 · 4 comments
Closed

1.0.0 Replacements for socket.set() and socket.get() #1481

doughsay opened this issue Apr 1, 2014 · 4 comments

Comments

@doughsay
Copy link

doughsay commented Apr 1, 2014

You used to be able to store arbitrary data along with a socket, using socket.get(key, callback) and socket.set(key, value, callback). How can we do this in 1.0.0?

Just setting random values on the socket seems to work, but doesn't sound safe. e.g. socket.foo = 'bar'.

@rauchg
Copy link
Contributor

rauchg commented Apr 1, 2014

It definitely should be safe to store properties on the object. The reason I'm removing it is that I don't want persistence at the socket.io layer. We can build that in other modules.

I'm definitely including a polyfill as part of the migration guide, however.

@rauchg rauchg closed this as completed Apr 1, 2014
@ghost
Copy link

ghost commented Jul 9, 2014

@guille Is it ready in 0.9.x as well? To make code ready for 1.0 and get rid of those get and set calls adding unnecessary callback nesting? Or object passed as socket can change identity while retaining the same id, client connection and attributes?

@miklschmidt
Copy link

I don't see any polyfill in the migration guide. How is this done in 1.0 exactly?

i'm using this as middleware for now:

configurable = require 'configurable'
module.exports = (socket, next) ->
    configurable socket
    next()

@lukewendling
Copy link

Any resolution or best practice for replacing old .set() and .get() -> we should instead use a prop directly on client object? Is there a module ( as mentioned above ) that does this more elegantly?

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

5 participants
@lukewendling @rauchg @doughsay @miklschmidt and others