Widdershin / cycle-restart

Swap out the code in your Cycle.js apps on the fly!
MIT License
123 stars 11 forks source link

Restartable removes prototype functions from DOMSource #56

Closed alisd23 closed 7 years ago

alisd23 commented 8 years ago

With the new Cycle diversity release candidates, the @cycle/dom driver source has a select function on its prototype, then I think the wrapSource function strips all the prototype functions out when it does this code:

Object.keys(source).forEach(function (key) {
  var value = source[key];

  if (key === 'dispose') {
    returnValue[key] = makeDispose({ streams: streams }, value);
  } else if (typeof value === 'function') {
    returnValue[key] = wrapSourceFunction({ streams: streams, addLogEntry: addLogEntry }, key, value, returnValue, scope);
  } else {
    returnValue[key] = value;
  }
});

As object.keys only loops over properties, not the prototype, it never adds the select function to the return value object.

I can put a pull request if you'd like to fix this. Using a for...in loop should do the trick.

alisd23 commented 8 years ago

Actually this is a bigger fix than I thought. This would require a complete rewrite to use xStream instead of rx, and some methods like pausable() don't exist in xStream.

Widdershin commented 8 years ago

complete rewrite to use xStream instead of rx

This is very much on the cards. I'll make a milestone and start adding issues to it.

Widdershin commented 7 years ago

I think this issue is addressed now. for...in is used to find keys and the DOM driver works in unified.

I'm going to close this, please reopen it if you find any more issues along these lines. 😄