leptos icon indicating copy to clipboard operation
leptos copied to clipboard

Implement several into traits for store fields

Open mahdi739 opened this issue 1 year ago • 1 comments

This PR implements these traits:

  • IntoClass
  • IntoStyle
  • IntoProperty
  • Render
  • RenderHtml
  • AttributeValue
  • InnerHtml

for these store fields:

  • Store
  • ArcStore
  • Field
  • ArcField
  • SubField
  • AtKeyed
  • KeyedSubField
  • DerefedField
  • AtIndex

Implementation for Store, Field, ArcStore, and ArcField was approachable easily by existing macro rules for signals, but for other store fields, I had to write new macro rules. Maybe someone can unify them with a better design.

The implementation of AddAnyAttr for signals was empty and marked with todo!(). I also added this empty implementation to new macros.

~~I didn't put them under the "reactive_stores" feature flag. Please let me know if I should do so.~~ I put them under the "reactive_stores" feature flag.

Additionally, it implements IntoSplitSignal for AtKeyed, AtIndex, and DerefedField.

This PR is written based on the previous PR (#3569), which had rewritten the implementation of signals to use try_get() instead of get().

mahdi739 avatar Feb 11 '25 05:02 mahdi739

This is getting out of hand, now there are two of them!

Would we want to merge this one and the other one? Overall I think using .try_get() is a decent solution here for panic prevention, but I am worried that instead of getting a panic it seems like this implementation just eats the error. I imagine it would have to emit an error somewhere user visible, whether that's the console in the browser or the server log on the server

benwis avatar Feb 14 '25 03:02 benwis

I close this PR in favor of the new PR: #3658

mahdi739 avatar Feb 27 '25 14:02 mahdi739