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
Expected behavior
Expected to be able to trigger a resource to refetch using Trigger::notify()
Additional context
It seems more like a usability/documentation issue than an actual bug. It makes perfect sense when I went and looked at the code of the Resource but it wasn't the behaviour I expected.
As a minimum, updating the documentation of Resource/create_resource to point out that the source is memoized would be good.
One possible way to fix it (assuming you agree Triggers should always trigger Memos and Resources) would be to have the Trigger return a private type that always returns false to PartialEq.
The text was updated successfully, but these errors were encountered:
As you note this is 100% a documentation issue; resource memoize the input signal. In fact this is not specific to triggers: since calling .track() on any signal returns (), this would be true for any other signal.track() used in the input signal. The canonical solution is to trigger resources with some kind of incrementing usize signal instead.
The proposed solution to return a ZST that is always != to itself from Track is an interesting one. I'd have to think about what other things it might break, of course -- and it would definitely be a breaking change that may affect user code.
Describe the bug
Passing a trigger as the source of a Resource doesn't work because Resource creates a memo from the source.
Leptos Dependencies
To Reproduce
Expected behavior
Expected to be able to trigger a resource to refetch using Trigger::notify()
Additional context
It seems more like a usability/documentation issue than an actual bug. It makes perfect sense when I went and looked at the code of the Resource but it wasn't the behaviour I expected.
As a minimum, updating the documentation of Resource/create_resource to point out that the source is memoized would be good.
One possible way to fix it (assuming you agree Triggers should always trigger Memos and Resources) would be to have the Trigger return a private type that always returns false to PartialEq.
The text was updated successfully, but these errors were encountered: