forked from cesarParra/lwc-signals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduces the ability to make objects and array changes reacti…
…ve by "tracking" them ## Summary To improve that experience, you can now set a `track` flag when creating the signal. When set to true, this will make the signal reactive to changes in the object or array properties. > 📒 Think about this as using the `@track` decorator in LWC properties. It works the exact same way behind the scenes. ```javascript import { $signal } from "c/signals"; const obj = $signal({ x: 1, y: 2 }, { track: true }); const computedFromObj = $computed(() => obj.value.x + obj.value.y); // When a value in the object changes, the computed value will automatically update obj.value.x = 2; console.log(computedFromObj.value); // 4 ```
- Loading branch information
1 parent
7dbdeed
commit 8a6bdf4
Showing
64 changed files
with
2,516 additions
and
847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
<div>Contact Name: {contactInfo.contactName}</div> | ||
</div> | ||
</div> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ export default class BusinessCard extends LightningElement { | |
contactName: contactName.value | ||
}) | ||
).value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
value={contactName} | ||
onchange={handleContactNameChange} | ||
></lightning-input> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ export default class CountChanger extends LightningElement { | |
decrementCount() { | ||
counter.value--; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<template> | ||
The current count is ($computed reactive property): {reactiveProperty} <br /> | ||
The counter plus two value is (nested computed): {counterPlusTwo} | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/server-communication/classes/ResourceController.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
options={accounts} | ||
onchange={handleAccountChange} | ||
></lightning-select> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
examples/server-communication/lwc/serverFetcher/serverFetcher.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
<!-- Server Fetcher --> | ||
<template> | ||
<template if:true={contacts.loading}> | ||
Loading | ||
</template> | ||
<template if:true={contacts.loading}> Loading </template> | ||
<template if:false={contacts.loading}> | ||
<template for:each={contacts.data} for:item="contact"> | ||
<div key={contact.Id}> | ||
<p>{contact.Name}</p> | ||
</div> | ||
</template> | ||
</template> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/shopping-cart/controllers/ShoppingCartController.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<template></template> | ||
<template></template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
examples/shopping-cart/lwc/checkoutButton/states/loading.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div class="mx-auto max-w-4xl pb-16"> | ||
<c-stencil height="50"></c-stencil> | ||
</div> | ||
</template> | ||
<div class="mx-auto max-w-4xl pb-16"> | ||
<c-stencil height="50"></c-stencil> | ||
</div> | ||
</template> |
41 changes: 20 additions & 21 deletions
41
examples/shopping-cart/lwc/checkoutButton/states/ready.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
<template> | ||
<div class="mx-auto max-w-4xl pb-16"> | ||
<div class="mt-10"> | ||
<button type="submit" | ||
disabled={isEmpty} | ||
class="w-full rounded-md border border-transparent bg-indigo-600 px-4 py-3 | ||
text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none | ||
focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-50 | ||
disabled:opacity-50 disabled:cursor-not-allowed"> | ||
Checkout | ||
</button> | ||
</div> | ||
<div class="mx-auto max-w-4xl pb-16"> | ||
<div class="mt-10"> | ||
<button | ||
type="submit" | ||
disabled={isEmpty} | ||
class="w-full rounded-md border border-transparent bg-indigo-600 px-4 py-3 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-50 disabled:opacity-50 disabled:cursor-not-allowed" | ||
> | ||
Checkout | ||
</button> | ||
</div> | ||
|
||
<div class="mt-6 text-center text-sm text-gray-500"> | ||
<p> | ||
or | ||
<a href="#" class="font-medium text-indigo-600 hover:text-indigo-500"> | ||
Continue Shopping | ||
<span aria-hidden="true"> →</span> | ||
</a> | ||
</p> | ||
</div> | ||
<div class="mt-6 text-center text-sm text-gray-500"> | ||
<p> | ||
or | ||
<a href="#" class="font-medium text-indigo-600 hover:text-indigo-500"> | ||
Continue Shopping | ||
<span aria-hidden="true"> →</span> | ||
</a> | ||
</p> | ||
</div> | ||
</template> | ||
</div> | ||
</template> |
2 changes: 1 addition & 1 deletion
2
examples/shopping-cart/lwc/shoppingCartDetails/shoppingCartDetails.js-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
examples/shopping-cart/lwc/shoppingCartDetails/states/loading.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<!-- loading --> | ||
<template> | ||
<div class="mx-auto max-w-4xl px-4 items-center justify-center flex"> | ||
<c-stencil height="419" width="864"></c-stencil> | ||
</div> | ||
<div class="mx-auto max-w-4xl px-4 items-center justify-center flex"> | ||
<c-stencil height="419" width="864"></c-stencil> | ||
</div> | ||
</template> |
Oops, something went wrong.