SolidJSS
SolidJS3y ago
8 replies
hotshoe

Breaking out proxied Stores object as a signal (while retaining reactivity)

Let's say I have an album object...
type Album = {
    id: string;
    artist: string;
    rating?: number
    // etc. 
}

, composed as Store array....
const [collection, setCollection] = createStore<Album[]>([]);


Now, the user can swipe through using Swiper (or similar), which Solidjs makes wonderfully straight-forward to implement using For control "tag".

Question: What is the best Solid pattern for passing selected item as a property to a properties page while retaining reactivity? In other words, when the user clicks (selects) a Swiper slide, a callback fn sends the
id
, which is used to bind the properties page (enabling user to add/edit the Album property fields).

I understand from watching some of Ryan's videos (so helpful and insightful!) that a Store is composed of signal primitives, so, in theory (I think ¯\_(ツ)_/¯) , I should be able to get at a proxied object and pass it as a signal, just as if I were passing a signal as a property. The alternative is to pass the store and the id to the props page (or break it out into context), but I'd prefer to be surgical, but not clear to me how to go about handling. Any ideas much appreciated? I'm still very much getting my feet wet w/ SolidJS (just a couple days into it), so apologies in advance if covered in the doc (I did check).

Thanks!

-Roland.
Was this page helpful?