File tree Expand file tree Collapse file tree
content/4-component-composition/5-context/alpine Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -434,7 +434,7 @@ How do we solve this ? Developers love having framework overview by examples. It
434434 <summary >
435435 <img width="18" height="18" src="static/framework/alpine.svg" />
436436 <b>Alpine</b>
437- <img src="https://us-central1-progress-markdown.cloudfunctions.net/progress/96 " />
437+ <img src="https://us-central1-progress-markdown.cloudfunctions.net/progress/100 " />
438438 </summary >
439439
440440- [x] Reactivity
@@ -451,12 +451,12 @@ How do we solve this ? Developers love having framework overview by examples. It
451451- [x] Lifecycle
452452 - [x] On mount
453453 - [x] On unmount
454- - [ ] Component composition
454+ - [x ] Component composition
455455 - [x] Props
456456 - [x] Emit to parent
457457 - [x] Slot
458458 - [x] Slot fallback
459- - [ ] Context
459+ - [x ] Context
460460- [x] Form input
461461 - [x] Input text
462462 - [x] Checkbox
Original file line number Diff line number Diff line change 1+ <!-- x-text must be called on or inside an x-data block. -->
2+ <!-- The two could have a shared parent with x-data, or each could individually have x-data like so: -->
3+
4+ < h1 x-data >
5+ Welcome back, < span x-text ="$store.user.username "> unknown user</ span >
6+ </ h1 >
7+
8+ < div x-data >
9+ < h2 > My Profile</ h2 >
10+ < p > Username: < span x-text ="$store.user.username "> </ span > </ p >
11+ < p > Email: < span x-text ="$store.user.email "> </ span > </ p >
12+ < button @click ="$store.user.updateUsername('Jane') ">
13+ Update username to Jane
14+ </ button >
15+ </ div >
16+
17+ < script >
18+ document . addEventListener ( "alpine:init" , ( ) => {
19+ Alpine . store ( "user" , {
20+ id : 1 ,
21+ username : "unicorn42" ,
22+ email : "unicorn42@example.com" ,
23+
24+ updateUsername ( newUsername ) {
25+ this . username = newUsername ;
26+ } ,
27+ } ) ;
28+ } ) ;
29+ </ script >
You can’t perform that action at this time.
0 commit comments