Closed bicarlsen closed 3 months ago
That sounds very resonable but I have no idea how to archieve this unfortunately. Do you have any pointers?
Looking at the source for create_signal
it looks like we would need to patch the doesn't seem we have access to the defined_at
field. Unfortunately, it doesn't look like we have access to it currently.
Maybe @gbj or @benwis can give some insight.
Adding #[track_caller]
to this and similar function definitions should work:
https://github.com/Synphonyte/leptos-use/blob/9c035d50d8fb9265a5d2761af57372e5c45f3ecd/src/utils/signal_filtered.rs#L10
Basically signal creation uses std::panic::Location::caller()
. Calling that returns the location where... well, it was called. But if you add #[track_caller]
it basically says "ignore the current function definition, and move up the stack". So the "Defined at" location is roughly "the last nested function call that wasn't marked #[track_caller]
"
Does that explanation make sense? If not I can expand on it. Basically I would assume most fn
definitions in a library like this that create signals somewhere inside them should be marked #[track_caller]
He beat me to it!
Thanks, that sounds good!
Sweet! @maccesch, would you like me to do the PR, or are you handling it?
Thanks @gbj and @maccesch for all the great help :)
Yeah if you could do a PR that would be awesome!
If a
signal_debounced
(and I assumesignal_throttled
but haven't verfied this) is used outside a reactive tracking context, the warning gives the signal's definition location asleptos-use-0.10.10/src/signal_debounced.rs:6:1
instead of the location wheresignal_debounced
is being called.Ideally the location of the
signal_debounced
call would be set as the definition location of the signal.