Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/coconut/react/View.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RenderResult>).onInvalidate(this);
}

public function invalidate()
@:privateAccess target.__react_setState({ revision: target.__react_state.revision + 1 });

public function destroy()
this.link.cancel();

Expand Down
Loading