Persistent server-side object for storing data server side #75

Merged
merged 1 commit into from Apr 29, 2011

Conversation

Projects
None yet
3 participants

eirikb commented Apr 27, 2011

Hello.

This is a simple example of how this.user can become a persistent server-side object.
Example of usage:
index.html:

<script type="text/javascript">
    now.ready(function() {
        now.hello('Hello, world');
        now.world(function(msg) {
            console.log(msg);
        });
    });
</script>

server.js:

var everyone = nowjs.initialize(server);

everyone.now.hello = function(msg) {
    this.user.test = msg;
};

everyone.now.world = function(callback) {
    callback(this.user.test);
};

Isn't there already a this.user object within the scope of the called function?

eirikb commented Apr 28, 2011

Yes, but it is sent in every time, so it is not persistent on the server side.
As in my example would not work since test would no longer exists in the world-function.

Contributor

sridatta commented Apr 28, 2011

This is a good idea, eirikb . There are several other places where we create a one-time user object. I'll change those other places to use a persistent user object and then merge your pull request.

eirikb commented Apr 28, 2011

Awesome

@sridatta sridatta added a commit that referenced this pull request Apr 29, 2011

@sridatta sridatta Merged pull request #75 from eirikb/master.
Persistent server-side object for storing data server side (partial implementation)
c32f773

sridatta merged commit c32f773 into Flotype:master Apr 29, 2011

Contributor

sridatta commented Apr 29, 2011

Implemented in github master. npm soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment