Gozala / reducers

Library for higher-order manipulation of collections
MIT License
181 stars 8 forks source link

Step through debugging #46

Open Raynos opened 11 years ago

Raynos commented 11 years ago

Try stepping through code that uses reducers with a debugger. It's almost impossible to make any sense of it.

Is there something we can do to rejig the implementation that makes it easier to debug

Gozala commented 11 years ago

One thing I plan to implement is introspect function that I believe will improve debugging story. I also hope browsers will get better at this. I know Anton already started implementing it for Firefox.

https://bugzilla.mozilla.org/show_bug.cgi?id=834506 https://code.google.com/p/chromium/issues/detail?id=172127&thanks=172127&ts=1359073198

Gozala commented 11 years ago

If you have any specific ideas I'm more than happy to explore.

Raynos commented 11 years ago

@Gozala there is a difference between debugging by printing and debugging by stepping through

Currently the way reducers/reducible works is that stepping through means you step through all these wrappers and proxies and never get to any meat. Stepping through is really hard to follow

Gozala commented 11 years ago

introspect won't be for printing it will let you stop throughput in specific scenarios and then tweak / pause / resume values send.

Raynos commented 11 years ago

@Gozala oh interesting. Show an example of it.

Gozala commented 11 years ago
var debugee = introspect(input, {
  next: function(value, result) {
     if (isMyCase(vaue, result)) {
       pause(debugee)
       console.log("Oops condition")
     }
  },
  end: function() {
    debugger;
  },
  error: function() {
     debugger;
  }
})

pause(debugee) // will buffer all values until resumed.
// you can tweak buffer
debugee.buffer.unshift("my thingy")
resume(debugee)