svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Transferring values from a layout to pages, or to components, and back

Open Gorbulev-Sergey opened this issue 4 months ago • 5 comments

Describe the problem

I know that you have a lot to do without me! Guys, I think it's very important to have functionality: to directly transfer values from the layout to pages, to components and back, from bottom to top. I know that you can use store or context, but it's inconvenient: context is limited in principle, and if you load the store with data from all components or pages, you can get confused about where the data comes from.

Describe the proposed solution

In children or component:

let {parent} = $props();
let myValueFromParent = parent.myValue;
myValueFromParent = "New value";

or

let myValueFromParent = $parent().myValue;
myValueFromParent = "New value";

or

let myValueFromParent = $parent(v=>v.myValue);
myValueFromParent = "New value";

In parent or layout:

let {children} = $props();
let myValueFromChildren = children.myValue;
myValueFromChildren = "New value";

or

let myValueFromChildren = $children().myValue;
myValueFromChildren = "New value";

or

let myValueFromChildren = $children(v=>v.myValue);
myValueFromChildren = "New value";

Importance

would make my life easier

Gorbulev-Sergey avatar Oct 30 '24 21:10 Gorbulev-Sergey