File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,30 @@ it lives—and builds a precise dependency graph in real-time.
4444The result is an API that is not only more powerful but also simpler and more intuitive, especially when it comes to
4545changing state. The provider does what you would expect, automatically handling complex scenarios like deep merging.
4646
47+ Where the magic truly begins is in how you * change* that data. Thanks to the new deep, proxy-based reactivity system,
48+ you can modify state with plain JavaScript assignments. It's as simple as it gets:
49+
50+ ``` javascript readonly
51+ // Get the provider and change the data directly
52+ const provider = myComponent .getStateProvider ();
53+
54+ // This one line is all it takes to trigger a reactive update.
55+ provider .data .user .firstname = ' Max' ;
56+
57+ // Does not overwrite the lastname
58+ provider .setData ({user: {firstname: ' Robert' }})
59+
60+ // You can update multiple properties at once. Thanks to automatic batching,
61+ // this results in only a single UI update cycle.
62+ provider .setData ({user: {firstname: ' John' , lastname: ' Doe' }})
63+
64+ // Alternative Syntax:
65+ provider .setData ({
66+ ' user.firstname' : ' John' ,
67+ ' user.lastname' : ' Doe'
68+ });
69+ ```
70+
4771``` javascript live-preview
4872import Button from ' neo.mjs/src/button/Base.mjs' ;
4973import Container from ' neo.mjs/src/container/Base.mjs' ;
You can’t perform that action at this time.
0 commit comments