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

Managed timers #407

Open
2 tasks done
npaton opened this issue Sep 2, 2023 · 0 comments
Open
2 tasks done

Managed timers #407

npaton opened this issue Sep 2, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@npaton
Copy link
Contributor

npaton commented Sep 2, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

We'd like to have timers that are managed by Empirica so they work seamlessly on a server restart.

Describe the solution you'd like

The initial request looked like this:

function myTimerCallback({game, time}) {
  console.log(`Its ${time}, setting to spooky mode)`)
  game.set("SpookyMode", true)
}

Empirica.on('game', 'start', (ctx, { game, start }) => {
  const midnightTonight = ... // epoch time
  const timerName = 'spookyTimer';
  game.registerTimer(midnightTonight, myTimerCallback, timerName)
}

I'm not sure we can register a timer callback once like this and have it work across restarts. But the general idea is here. What's the simplest API to make something like this possible and easy to use.

Describe alternatives you've considered

You can create timers right now, but you're doing it at the Tajriba level and it is cumbersome.

Teachability, Documentation, Adoption, Migration Strategy

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@npaton npaton added the enhancement New feature or request label Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant