File tree Expand file tree Collapse file tree 9 files changed +68
-30
lines changed
packages/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/method Expand file tree Collapse file tree 9 files changed +68
-30
lines changed Original file line number Diff line number Diff line change 11{
2- "entry" : " x/wire"
2+ "entry" : " x/parent" ,
3+ "ssrFiles" : {
4+ "error" : " error-v2.txt" ,
5+ "expected" : " expected-v2.html"
6+ }
37}
Original file line number Diff line number Diff line change 1+ < fixture-test >
2+ < template shadowrootmode ="open ">
3+ < x-wire >
4+ < template shadowrootmode ="open ">
5+ < div >
6+ Invocation sequence:
7+ 1. adapter: connect()
8+ 2. component: getApiValue(undefined)
9+ 3. adapter: update()
10+ 4. component: wiredMethod(wire provided value)
11+ 5. component: setApiValue(wire provided value)
12+ 6. component: setApiValue(parent provided (initial) value)
13+ </ div >
14+ < div >
15+ Api Value: parent provided (initial) value
16+ </ div >
17+ </ template >
18+ </ x-wire >
19+ </ template >
20+ </ fixture-test >
Original file line number Diff line number Diff line change 11< fixture-test >
22 < template shadowrootmode ="open ">
3- < div >
4- Invocation sequence:
5- 1. adapter connect()
6- 2. adapter update()
7- 3. component wiredMethod()
8- </ div >
9- < div >
10- Wired prop: {
11- key1: foo,
12- }
13- </ div >
3+ < x-wire >
4+ < template shadowrootmode ="open ">
5+ < div >
6+ Invocation sequence:
7+ 1. component: setApiValue(parent provided value)
8+ 2. adapter: connect()
9+ 3. component: getApiValue(parent provided value)
10+ 4. adapter: update()
11+ 5. component: wiredMethod(wire provided value)
12+ 6. component: setApiValue(wire provided value)
13+ </ div >
14+ < div >
15+ Api Value: wire provided value
16+ </ div >
17+ </ template >
18+ </ x-wire >
1419 </ template >
1520</ fixture-test >
Original file line number Diff line number Diff line change 1+ < template >
2+ < x-wire api-value ={apiValue} > </ x-wire >
3+ </ template >
Original file line number Diff line number Diff line change 1+ import { LightningElement } from 'lwc' ;
2+
3+ export default class Parent extends LightningElement {
4+ apiValue = 'parent provided (initial) value' ;
5+ }
Original file line number Diff line number Diff line change @@ -6,20 +6,12 @@ export class adapter {
66 }
77
88 connect ( ) {
9- invocationSequence . push ( 'adapter connect()' ) ;
9+ invocationSequence . push ( 'adapter: connect()' ) ;
1010 }
1111
12- update ( config ) {
13- invocationSequence . push ( 'adapter update()' ) ;
14- // JSON.stringify serializes differently for engine-server/ssr-compiler, so we do it manually
15- const output = Object . entries ( config )
16- . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) )
17- . map ( ( [ key , value ] ) => ` ${ key } : ${ JSON . stringify ( value ) } ,` )
18- . join ( '\n' )
19- // Quotes are encoded as " in the output, which makes it harder to read...
20- . replace ( / " / g, '' ) ;
21-
22- this . dc ( `{\n${ output } \n}` ) ;
12+ update ( ) {
13+ invocationSequence . push ( 'adapter: update()' ) ;
14+ this . dc ( 'wire provided value' ) ;
2315 }
2416
2517 disconnect ( ) { }
Original file line number Diff line number Diff line change 11< template >
22 < div > Invocation sequence: {invocationSequence}</ div >
3- < div > Wired prop : {externalProp }</ div >
3+ < div > Api Value : {apiValue }</ div >
44</ template >
Original file line number Diff line number Diff line change 1- import { LightningElement , wire } from 'lwc' ;
1+ import { LightningElement , wire , api } from 'lwc' ;
22
33import { adapter , invocationSequence } from './adapter' ;
44
55export default class Wire extends LightningElement {
6- prop = 'foo' ;
6+ @api
7+ set apiValue ( value ) {
8+ invocationSequence . push ( `component: setApiValue(${ value } )` ) ;
9+ this . _apiValue = value ;
10+ }
11+
12+ get apiValue ( ) {
13+ invocationSequence . push ( `component: getApiValue(${ this . _apiValue } )` ) ;
14+ return this . _apiValue ;
15+ }
716
8- @wire ( adapter , { key1 : '$prop ' } )
17+ @wire ( adapter , { apiValue : '$apiValue ' } )
918 wiredMethod ( value ) {
10- invocationSequence . push ( ' component wiredMethod()' ) ;
11- this . externalProp = value ;
19+ invocationSequence . push ( ` component: wiredMethod(${ value } )` ) ;
20+ this . apiValue = value ;
1221 }
1322
1423 get invocationSequence ( ) {
You can’t perform that action at this time.
0 commit comments