shakyShane / html-injector

BrowserSync html injector
78 stars 21 forks source link

Production ready? #9

Open shakyShane opened 9 years ago

shakyShane commented 9 years ago

This is a todo-list for tracking what I consider to be deal-breakers stopping me promoting & classifying this plugin as production ready.

stereokai commented 9 years ago

I have another point to bring into the discussion: Is this tool supposed to work with single page apps using frameworks like Angular, React, etc? Is this even viable? Let's consider:

With Angular we'll have to somehow force recompilation of directives. It shouldn't be that hard:

// 1. Get all instances of old template in live HTML

var instances = getTheContainerElementsFor(changedHTML);

// 2. Get the $compile service from the current app:

var $compile = angular.element('.ng-scope').injector().get('$compile');

// 3. Replace all instances with new HTML and compile with original scopes

instances.forEach((instance) => {
  var element = angular.element(instance);
  var scope = element.scope();

  $compile(element.replaceWith(changedHTML))(scope);
});

// 4. Wrap up with refreshing the whole up:

$scope.$apply();
stereokai commented 9 years ago

@shakyShane ?

shakyShane commented 9 years ago

Wow! if it's really that easy to hot-update angular directives I'd certainly be happy to support this. Would be pretty easy too, although I'm thinking it would be a separate BS plugin.

ArmorDarks commented 8 years ago

Any plans to continue development?