Code Monkey home page Code Monkey logo

Comments (17)

gjohnson avatar gjohnson commented on May 13, 2024

Just curious, what's the use case of having that? I have never used Emitter2... Just for debugging?

from axon.

sintaxi avatar sintaxi commented on May 13, 2024

It's so you can trigger events on more broad or narrow event descriptions. Eg:

sock.on('basketball.nba.bulls', function(data){
  // do this only for the bulls events
});

sock.on('basketball.nba.*', function(data){
  // do this for all nba events
});

sock.on('basketball.ncaa.*', function(data){
  // do this for all ncaa events
});

sock.on('basketball.*.*', function(data){
  // do this for all basketball events
});

sock.on('*.*.*', function(data){
  // log everything ...
});

from axon.

gjohnson avatar gjohnson commented on May 13, 2024

Gotcha, I will let @visionmedia decide on that. I could see some use cases where it could be beneficial (e.g a monitor system that emits alert types that you could pattern match on the other end, etc). Though I would opt for wrapping up a long over due release with all the new stuff we have in master first. The original project that pushed me to help on this project in the first place is coming back up, so I will finally have the time to head that up again...

from axon.

tj avatar tj commented on May 13, 2024

need to think on this haha, not against it. The one thing I don't like about their pattern matching is that * in my mind at least should match anything vs having to know the event segments. Maybe as a compromise we could support * only which would just punt the event name as an argument that you could match on. That's not as attractive though... hmm

from axon.

sintaxi avatar sintaxi commented on May 13, 2024

Yeah totally. I bring it up because it looks like hook.io is EOL and it gave you this. Not to turn axon into hook.io but it may be able to address some of the use cases. Not sure what the performance penalty of using EventEmitter2 is. perhaps having the choice of emitter or emitter2 may be worth considering.

from axon.

sintaxi avatar sintaxi commented on May 13, 2024

@visionmedia FWIW I agree regarding * and the event segment. May be a lot of work to do differently though.

from axon.

tj avatar tj commented on May 13, 2024

arguably that sort of thing could be part of the object(s) passed as well, sock.on('basketball', function(data){ data.league }) etc

from axon.

gjohnson avatar gjohnson commented on May 13, 2024

Just to clarify, I would argue that the emitter socket should remain as is, and follow the same feel as the node-core emitter. I would only see this being part of pub/sub through topics:

sock.subscribe('foo*'); // maybe even regexp
sock.on('message', function(msg){});

from axon.

tj avatar tj commented on May 13, 2024

EmitterSocket is definitely a higher level one, we could possibly just produce regexps for the .on() calls filter on "message", but then we lose the possibility of doing selective reception later on unless we do translate those to .subscribe()s

from axon.

tj avatar tj commented on May 13, 2024

this would help for having some stable relay nodes that would relay everything, I'm a little torn since in general you can just use multiple sockets for multiple "topics" but I can see how that would become less true with some scenarios. I'll try out some simple str -> regexp conversions and see what the impact is like and / or EE2. I'm not sure I'm sold on how EE2 handles separators though

from axon.

sintaxi avatar sintaxi commented on May 13, 2024

Thanks for the update. Let me know if there is anything I can do to help. I've been digging this library.

btw - I'm liking the glob-style pattern matching that redis gives you

from axon.

tj avatar tj commented on May 13, 2024

at very least we could add it as some sort of thing you opt-into if there ends up being a perf penalty worth caring about

from axon.

tj avatar tj commented on May 13, 2024

non-scientific benchmarks:

even our multipart support drastically reduces throughput,
so the overhead of regexp-based subscriptions relative to
that one is actually pretty low. I'm sure we could improve multipart,
my guess is .concat() is probably not great, maybe some other
things too


BEFORE:

    min: 244 ops/s
   mean: 145032 ops/s
 median: 20852 ops/s
  total: 109511 ops in 3.349s
through: 141.6328125 mb/s

    min: 3031 ops/s
   mean: 150450 ops/s
 median: 21432 ops/s
  total: 114290 ops in 2.592s
through: 146.923828125 mb/s

BEFORE (multipart):

    min: 244 ops/s
   mean: 80274 ops/s
 median: 150689 ops/s
  total: 94281 ops in 5.302s
through: 78.392578125 mb/s

AFTER (no subscriptions):

    min: 322 ops/s
   mean: 138694 ops/s
 median: 20565 ops/s
  total: 150902 ops in 4.105s
through: 135.443359375 mb/s

    min: 861 ops/s
   mean: 151069 ops/s
 median: 21248 ops/s
  total: 312569 ops in 9.340s
through: 147.5283203125 mb/s

AFTER (1 subscription):

    min: 389 ops/s
   mean: 70102 ops/s
 median: 15393 ops/s
  total: 98439 ops in 5.148s
through: 68.458984375 mb/s

AFTER (5 subscriptions):

    min: 325 ops/s
   mean: 67374 ops/s
 median: 14977 ops/s
  total: 137652 ops in 7.403s
through: 65.794921875 mb/s

from axon.

tj avatar tj commented on May 13, 2024

ah yup http://jsperf.com/concat-push/6

from axon.

sintaxi avatar sintaxi commented on May 13, 2024

wow.

from axon.

tj avatar tj commented on May 13, 2024

hmm removing that only gave me about ~10% increase, I'll profile later and see what's up

from axon.

tj avatar tj commented on May 13, 2024

https://github.com/visionmedia/axon/pull/new/add/emitter-wildcards

from axon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.