-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stale data returning when inputs changed #44
Comments
While I understand this is somewhat unexpected, this is intentional behavior. So, at this moment, what you did is something I expected as a usage, and I'd do the same. That said, I'm open for discussions. |
Perhaps a simple flag in the response would do the trick. For example, how I got around it now is that I pass in a
I make sure the output of the worker returns the same $inputKey in the resulting object. Then I can do this:
However, it's a pattern I will have to follow on every single use of this hook. If we could somehow use the dependency to flag it as stale because we're returning an old result, it would skip this step pretty easily. Basically adding a I just suspect that with the hook pattern, it will seem unexpected to be receiving stale results with no indication of them being stale. |
If this is not an option, this behavior should probably be described in the Readme |
Yeah, the notion of "stale" only works for RPC style (one request / one response). |
I believe I found a bug. When I pass in a value to a useWorker that relies on a param, the result appears to be cached. It's hard to explain... for the following code:
It produces console logs like this...
Then on change of
someParam
to be124
, I see:Basically, I have a hook that takes a prop that can change, and it takes tome to process the worker data (think a data fetch)... but when the param changes, the result/error values seem to be the ones corresponding to the previous param. I've gotten around it by making sure the value of
result.b
matchessomeParam
, but this seems like a bug?The text was updated successfully, but these errors were encountered: