Skip to content
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

change trigger #4

Open
moodymudskipper opened this issue Mar 29, 2024 · 2 comments
Open

change trigger #4

moodymudskipper opened this issue Mar 29, 2024 · 2 comments

Comments

@moodymudskipper
Copy link
Owner

To be able to trigger on change we need to store a value, check it, and when it's different than the last one, store the new and move on. I think it's a different function than f because:

  • f doesn't know the cycle's name (could be solved but not ideal)
  • I'm not sure if this can work in the background because we need to set the new value right after checking

So I believe we need a trigger arg, that's an argument-less function that returns a small value that identifies the state, for instance the date of the last received email if the feature is to notify new emails.

@moodymudskipper
Copy link
Owner Author

We also want to be able to store metadata that can be use by the hook

  • both the hook and the trigger should be able to get the meta data
  • and set it when possible (maybe background processes cannot store metadata ? we would need a hook when they finish, or poll them during the process, but it's complicated)

Now that we have the arg trigger, renaming f to hook might make sense.

I think we need to unify the API of new_cycle() and new_cycle_bg(), the hook in new_cycle() should also have args, and these are also set in the function's env. The function's env however should be a child of {stats} so our hooks cannot be corrupted by overrides values in the global env.

in the hook and the trigger's env we can have bindings to the cycle's metadata, excluding the process maybe because it's not useful and would be wrong in a background cycle.

@moodymudskipper
Copy link
Owner Author

A problem is that the hook not only doesn't know its name but its doesn't know its cycle either.
The hook can change the meta data we'd store in its environment but that won't change the cycle.
This can be synchronised when looping on cycles but I think w don't need this data in the cycle anyway, as long as it's contained in the env.

So,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant