thaw-ui / thaw

An easy to use leptos component library
https://thawui.vercel.app
MIT License
206 stars 21 forks source link

Adding implemenatation of From trait to Model for derived signals #189

Closed kandrelczyk closed 1 month ago

kandrelczyk commented 1 month ago

Hi,

I'm trying to do something like that:

let error : RwSignal<Option<SomeError>> = create_rw_signal(None);
let show_error = Signal::derive(move||error.get().is_some()); 

<Modal title="title" show=show_error>
   { display error}
</Modal> 

This didn't work because show has type Model and you can't create Model from derived signal.

I've added the From<Signal<T>> for Model<T> implementation and it's working now.

Is this a good approach? I think especially for components like Modal handling derived signal is very useful but maybe there's better way to do it.

kandrelczyk commented 1 month ago

Closing since it's not needed.