Skip to content

Commit 6e49f36

Browse files
authored
Merge pull request #33 from MVCoconut/issue-32
Try to make tink_state -> react binding via Invalidatable.
2 parents 6b5ebec + cf497fa commit 6e49f36

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/coconut/react/View.hx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,20 @@ class ViewBase extends NativeComponent<{ revision: Int }, {}, ImplicitContext> {
158158
}
159159
}
160160

161-
private class Binding {//TODO: try to make this an Invalidatable and use the actual Revision ... the last attempt led to infinite recursion though ¯\_(ツ)_/¯
161+
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 ¯\_(ツ)_/¯
162162

163163
final target:ViewBase;
164164
final link:CallbackLink;
165165

166166
public function new(target) @:privateAccess {
167167
this.target = target;
168-
var first = true;
169-
this.link = target.__rendered.bind(_ -> if (first) first = false else target.__react_setState({ revision: target.__react_state.revision + 1 }));
168+
// var first = true;
169+
this.link = (target.__rendered:ObservableObject<RenderResult>).onInvalidate(this);
170170
}
171171

172+
public function invalidate()
173+
@:privateAccess target.__react_setState({ revision: target.__react_state.revision + 1 });
174+
172175
public function destroy()
173176
this.link.cancel();
174177

0 commit comments

Comments
 (0)