cmawhorter / fancy

1 stars 2 forks source link

Components need some improvement #10

Open cmawhorter opened 8 years ago

cmawhorter commented 8 years ago

Components for data work pretty well, but the signature they use isn't great.

I also find myself doing string concat for html, which isn't great. Replace with something like HyperScript?

cmawhorter commented 8 years ago

The current signature:

module.exports = function($el, callback) {
  $el.replaceWith('<p>Hello!</p>');
  callback(null);
};

Using promises here would probably make more sense:

module.exports = function($el) {
  var deferred = create_promise;
  $el.replaceWith('<p>Hello!</p>');
  setTimeout(deferred.resolve.bind(deferred), 0);
  return deferred; // if promise not returned, could be considered sync
};

module.exports = function($el) {
  $el.replaceWith('<p>Hello!</p>');
  // if promise not returned, could be considered sync
  // return deferred; 
};