-
Notifications
You must be signed in to change notification settings - Fork 260
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
What's the reason updateAction
API doesn't allow modifiction?
#535
Comments
updateAction
API doesn't modifiction?updateAction
API doesn't allow modifiction?
Can you clarify what kind of API you're looking for, ideally with a type signature? |
So, I was looking for something like the following
That way, when run run the first time it is called with |
I'm not actually seeing how such a function would work. Are you missing a parameter? Is this intended to be a field in a data type? |
@nanonaren wants something like this I think: foobar :: IO (IO Text)
foobar = mkAutoUpdate defaultUpdateSettings
{ updateAction = \maybePreviousValue -> foo -- Potentially use previous value to calculate the new value
, updateFreq = 24 * 60 * 60 * 1000000 -- Update once per day
} @nanonaren It would probably help clarify things if you provided an example use case |
The example by @MaxGabriel is what I'm looking for. I have a structure in memory that gets updated periodically. Specifically, it maintains a vector of computed values based on recent data in the DB. So it pulls in records after the last update time and then drops very old items. This is why I need to update the previous value rather than refresh it with a completely new one. |
OK, that makes sense. To provide for maximum performance and not break backwards compatibility, I'd imagine we could add a new field: updateActionModify :: Maybe (a -> IO a) The idea would be:
|
@nanonaren Are you interested in implementing this? |
Sure, I'll do it. Please check if it makes sense... |
^ anyone want to check? |
LGTM. I didn't review this earlier since Github doesn't send notifications for commits pinging issues/PRs. |
Is there any particular reason for
Control.AutoUpdate.updateAction
not providing an API to update the existing value? Seems rather a useful thing to have to me.The text was updated successfully, but these errors were encountered: