You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is this the intended way to pass procedure to a component?
#568
Hello, I'm playing with topcoat runtime, trying to make an universal edit component, is this the right way to pass a procedure to a component? Or what is the best approach, I would like to edit single db field and update only that field, I do not want to reload the whole page. Thanks.
#[procedure]pub(super)asyncfntest_save(id:i64,value:String) -> Result<String>{let msg = format!("{id}: {value}");println!("{msg}");Ok(value)}// Test whether a procedure can be passed as a generic// component argument and invoked inside an expression.#[component]asyncfntest_editor<P>(cx:&Cx,id:i64,save:P,) -> Result<implView>whereP:TypedProcedure<Args = (i64,String),Output = String>
+ Surrogated<Surrogate = &'staticProcedureSurrogate<P>>
+ Copy,{let value = signal(cx, || String::from("test"));Ok(view!{
button(
variant:ButtonVariant::Ghost,
attrs: attributes! {type="button"
@click=$(async |_e:Event| {let saved = save(id, value.get()).await;
value.set(saved);})},"Cancel")
<p>$(value.get())</p>
})}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hello, I'm playing with topcoat runtime, trying to make an universal edit component, is this the right way to pass a procedure to a component? Or what is the best approach, I would like to edit single db field and update only that field, I do not want to reload the whole page. Thanks.
All reactions