Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/parent"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<fixture-test>
<template shadowrootmode="open">
<x-wire>
<template shadowrootmode="open">
<div>
Invocation sequence:
1. component: setApiValue(parent provided (initial) value)
2. adapter: connect()
3. component: getApiValue(parent provided (initial) value)
4. adapter: update()
5. component: wiredMethod(wire provided value)
6. component: setApiValue(wire provided value)
</div>
<div>
Api Value: wire provided value
</div>
</template>
</x-wire>
</template>
</fixture-test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<x-wire api-value={apiValue}></x-wire>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LightningElement } from 'lwc';

export default class Parent extends LightningElement {
apiValue = 'parent provided (initial) value';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export let invocationSequence = [];

export class adapter {
constructor(dataCallback) {
this.dc = dataCallback;
}

connect() {
invocationSequence.push('adapter: connect()');
}

update() {
invocationSequence.push('adapter: update()');
this.dc('wire provided value');
}

disconnect() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div>Invocation sequence: {invocationSequence}</div>
<div>Api Value: {apiValue}</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { LightningElement, wire, api } from 'lwc';

import { adapter, invocationSequence } from './adapter';

export default class Wire extends LightningElement {
@api
set apiValue(value) {
invocationSequence.push(`component: setApiValue(${value})`);
this._apiValue = value;
}

get apiValue() {
invocationSequence.push(`component: getApiValue(${this._apiValue})`);
return this._apiValue;
}

@wire(adapter, { apiValue: '$apiValue' })
wiredMethod(value) {
invocationSequence.push(`component: wiredMethod(${value})`);
this.apiValue = value;
}

get invocationSequence() {
return invocationSequence.map((invocation, i) => `\n ${i + 1}. ${invocation}`).join('');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/wire"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<fixture-test>
<template shadowrootmode="open">
<div>
Wire adapter invocation sequence:
1. adaptor connect()
2. adaptor update()
</div>
<div>
Wired prop: true
</div>
</template>
</fixture-test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export let invocationSequence = [];

export class adapter {
constructor(dataCallback) {
this.dc = dataCallback;
}

connect() {
invocationSequence.push('adaptor connect()');
}

update() {
invocationSequence.push('adaptor update()');
this.dc(true);
}

disconnect() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<div>Wire adapter invocation sequence: {invocationSequence}</div>
<div>Wired prop: {wiredProp}</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { LightningElement, wire } from 'lwc';

import { adapter, invocationSequence } from './adapter';

export default class Wire extends LightningElement {
@wire(adapter)
wiredProp;

get invocationSequence() {
return invocationSequence.map((invocation, i) => `\n ${i + 1}. ${invocation}`).join('');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const bGenerateMarkup = esTemplate`
});

__establishContextfulRelationship(contextfulParent, instance);
${/*connect wire*/ is.statement}

instance[__SYMBOL__SET_INTERNALS](
props,
Expand All @@ -59,6 +58,7 @@ const bGenerateMarkup = esTemplate`
instance.connectedCallback();
__mutationTracker.disable(instance);
}
${/*connect wire*/ is.statement}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🎉🎉

// If a render() function is defined on the class or any of its superclasses, then that takes priority.
// Next, if the class or any of its superclasses has an implicitly-associated template, then that takes
// second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template.
Expand Down