I want to use preact with websockets. But I wonder is it possible using with EventEmitter likes facebook's one.
@mehmetkose you can just use the same EventEmitter (the Facebook one). Shouldn't be any different in preact. We have a 200 byte functional version of EventEmitter we'll likely release soon, but for now Facebook's seems reasonable.
(Closing since I think that answers your question, but let me know if I missed the point!)
@developit no question. thank you.
I built a port of Node's EventEmitter that is smaller, more functional and independent from other Node libs. I am using it with Preact. It can be found here:
It's pre-1.0.0 so any feedback is welcome!
We have a 200 byte functional version of EventEmitter we'll likely release soon
Sounds interesting! Maybe we could combine our efforts? My current implementation is a full port, but this could probably be trimmed down.
Wow that looks like an amazing drop-in for events - have you thought about submitting it as an official "browser" alias for the node module? Nice work!
Thanks! Well, the original EventEmitter from Node can already be used in the browser. It just pulled in some dependencies that I didn't want. When using React you hardly notice it, but with Preact you see how your bundle more than doubles in size when you pull in EventEmitter from Node because Preact is so tiny! :) So it seemed too much of a waste to do that...
It turns out that more modules pull in more than we bargained for... I also ended up creating my own version of debug, named ulog and I also forked Kriasoft's Universal Router and named it uroute. The reason I don't use preact-router is because I am doing server-side rendering and want to start rendering the page before the data has come back from e.g the database. So I need a router where I can easily decouple routing from rendering. But Universal Router (while a brilliant piece of code) uses Generators, which requires the Babel generator runtime, which is too big for my liking. So... :)
That's awesome. I wonder if we can find a way to transpile generators to something smaller?
Most helpful comment
Thanks! Well, the original EventEmitter from Node can already be used in the browser. It just pulled in some dependencies that I didn't want. When using React you hardly notice it, but with Preact you see how your bundle more than doubles in size when you pull in EventEmitter from Node because Preact is so tiny! :) So it seemed too much of a waste to do that...
It turns out that more modules pull in more than we bargained for... I also ended up creating my own version of
debug, named ulog and I also forked Kriasoft's Universal Router and named it uroute. The reason I don't use preact-router is because I am doing server-side rendering and want to start rendering the page before the data has come back from e.g the database. So I need a router where I can easily decouple routing from rendering. But Universal Router (while a brilliant piece of code) uses Generators, which requires the Babel generator runtime, which is too big for my liking. So... :)