senecajs-attic / varo

pattern matched composition for browser apps
MIT License
7 stars 6 forks source link

Handle should happen before Observe #2

Closed mcdonnelldean closed 8 years ago

mcdonnelldean commented 8 years ago

@mcollina Might need a look off you one this one. My observers get the pattern before the handler does. Logically in code, this makes sense, the handler is a callback. But I would like to handle observers after the fact as they are second in priority. Any ideas.

Logic is here: https://github.com/senecajs/varo/blob/master/lib/varo.js#L17-L41

mcollina commented 8 years ago
  1. You should encapsulate the Parralel instance in the instance.
  2. Do not allocate next and complete, but rather instantiate an object as state, and stick everything in there. This is roughly 20-100% faster than allocating those function, see https://github.com/mcollina/aedes/blob/master/aedes.js#L201-L212 as an example.
  3. I would call the handler first, store the result in the State object, and then call the observe handlers.

Basically you should never allocate a callback, if you want your code to be fast :).

mcdonnelldean commented 8 years ago

@mcollina That's why you're my hero :D

mcdonnelldean commented 8 years ago

@mcollina Removed a lot of this code in the end, split emit() and act() to simplify usage of each. Will move to steed over fastparallel. This should give me what I am looking for here. For now, this can be closed. Thanks for the input.