YuukanOO / streamy

Use meteor underlying sockets for realtime communications
https://atmospherejs.com/yuukan/streamy
MIT License
105 stars 20 forks source link

documentation enhancement: Description of Core functions #3

Closed TomFreudenberg closed 9 years ago

TomFreudenberg commented 9 years ago

Hi,

I would suggest to move the description of CORE functions (your beginning chapter) near the end of the README just as the chapter behind Direct Communication.

Therfor you start with a simple example of Broadcast which works driectly for new users. I made the fault to start with

Streamy.emit('topic', { msg: "my data" });

on server part.

This won't raise an error but also won't reach any client cause, .emit on server needs a socket.

To avoid first time usage beginning with "frustration" I would prefer to start with the easy working broadcasting example.

My 10 cents Tom

YuukanOO commented 9 years ago

I added a Basic Usage section. Tell me what you think about it :)

TomFreudenberg commented 9 years ago

Hi Julien,

that's all pretty nice. In case that I like the KISS principle as said, I would shorten the basic usage just to:

// Attach a client handler for custom message type
Streamy.on('hello', function(d) {
  console.log(d.data); // Will print 'world!'
});

// Push a message to all connected listeners from any client or server
Streamy.broadcast('hello', { data: 'world!' });

Thereafter you could continue with your Core paragraph as you did already.

Cheers Tom

YuukanOO commented 9 years ago

Hmmm, I still want to show that you can send a message to the server only. I think that's the core of the project so I guess I should let it that way.

TomFreudenberg commented 9 years ago

np, it is your decision ;-)

For me the core function is to broadcast from server to client but that depends on how you use this library and what is your own project about.