Skip to content

Commit 6b20ca7

Browse files
committed
bug #926 [Live] Removing docs showing the proxied component (weaverryan)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Live] Removing docs showing the proxied component | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | None | License | MIT 3 small things: 1) The docs were wrong - calling `this.component.set()` does not, on its own, trigger a re-render. `this.component.render()` is also needed. 2) When using `getComponent()`, the `Proxy` wrapped object is not returned, so doing things like `this.someModel = 'bar'` does not work. And I think we shouldn't make it work - the `Proxy` is just some unnecessary magic and it would add complexity to introduce it here. 3) The interval was never cleared - minor, but we were running the interval a few extra times after returning times. Cheers! Commits ------- ccd4e5d [Live] Removing docs showing the proxied component
2 parents 0949f97 + ccd4e5d commit 6b20ca7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,7 @@ class ComponentRegistry {
26212621
const interval = setInterval(() => {
26222622
const component = this.componentMapByElement.get(element);
26232623
if (component) {
2624+
clearInterval(interval);
26242625
resolve(component);
26252626
}
26262627
count++;

src/LiveComponent/assets/src/ComponentRegistry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class {
2525
const interval = setInterval(() => {
2626
const component = this.componentMapByElement.get(element);
2727
if (component) {
28+
clearInterval(interval);
2829
resolve(component);
2930
}
3031
count++;

src/LiveComponent/doc/index.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,13 +771,11 @@ controller and put it around (or attached to) your root component element:
771771
toggleMode() {
772772
// e.g. set some live property called "mode" on your component
773773
this.component.set('mode', 'editing');
774-
// you can also say
775-
this.component.mode = 'editing';
774+
// then, trigger a re-render to get the fresh HTML
775+
this.component.render();
776776
777777
// or call an action
778778
this.component.action('save', { arg1: 'value1' });
779-
// you can also say:
780-
this.component.save({ arg1: 'value1'});
781779
}
782780
}
783781

0 commit comments

Comments
 (0)