Skip to content
Snippets Groups Projects
Commit cdd88838 authored by Tom Robinson's avatar Tom Robinson
Browse files

Cleanup mbReactComponent

parent 5bbb7d60
No related branches found
No related tags found
No related merge requests found
......@@ -142,22 +142,22 @@ CorvusDirectives.directive('mbReactComponent', ['$timeout', function ($timeout)
function render() {
var props = {};
for (var key in scope) {
var value = scope[key];
function copyProp(key, value) {
if (typeof value === "function") {
(function(value) {
props[key] = function() {
try {
return value.apply(this, arguments);
} finally {
$timeout(() => scope.$digest());
}
props[key] = function() {
try {
return value.apply(this, arguments);
} finally {
$timeout(() => scope.$digest());
}
})(value);
}
} else {
props[key] = value;
}
}
for (var key in scope) {
copyProp(key, scope[key]);
}
React.render(<Component {...props}/>, element[0]);
}
......@@ -170,8 +170,8 @@ CorvusDirectives.directive('mbReactComponent', ['$timeout', function ($timeout)
scope.$watch(function() {
if (!timeout) {
timeout = requestAnimationFrame(function() {
timeout = null;
render();
timeout = null;
render();
});
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment