diff --git a/src/coconut/react/View.hx b/src/coconut/react/View.hx index f621182..094e113 100644 --- a/src/coconut/react/View.hx +++ b/src/coconut/react/View.hx @@ -158,17 +158,20 @@ class ViewBase extends NativeComponent<{ revision: Int }, {}, ImplicitContext> { } } -private class Binding {//TODO: try to make this an Invalidatable and use the actual Revision ... the last attempt led to infinite recursion though ¯\_(ツ)_/¯ +private class Binding implements Invalidatable {//TODO: try to make this an Invalidatable and use the actual Revision ... the last attempt led to infinite recursion though ¯\_(ツ)_/¯ final target:ViewBase; final link:CallbackLink; public function new(target) @:privateAccess { this.target = target; - var first = true; - this.link = target.__rendered.bind(_ -> if (first) first = false else target.__react_setState({ revision: target.__react_state.revision + 1 })); + // var first = true; + this.link = (target.__rendered:ObservableObject).onInvalidate(this); } + public function invalidate() + @:privateAccess target.__react_setState({ revision: target.__react_state.revision + 1 }); + public function destroy() this.link.cancel();