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

how to pause #71

Open
mokun opened this issue Jun 15, 2018 · 2 comments
Open

how to pause #71

mokun opened this issue Jun 15, 2018 · 2 comments

Comments

@mokun
Copy link

mokun commented Jun 15, 2018

How do I pause and resume using Timer ?

I followed your approach in http://tomasmikula.github.io/blog/2014/06/04/timers-in-javafx-and-reactfx.html

In javafx, I can do

Timeline autosaveTimer = new Timeline(
				new KeyFrame(Duration.seconds(60 * MINUTES),
						ae -> masterClock.setSaveSim(DEFAULT))); 

At some point I have to call autosaveTimer().pause() to pause

and later call autosaveTimer().play() to resume

In ReactFX, I do the following

Timer autosaveTimer = FxTimer.runLater(
    				java.time.Duration.ofMinutes(60 * MINUTES),
    		        () -> masterClock.setSaveSim(DEFAULT)));

I notice there is a stop() and restart() for Timer

but I don't want to stop autosaveTimer completely and restart from the beginning of MINUTES. I want to resume from whatever MINUTES has elapsed.

Is there a pause() and resume() that I can call ?

@schlegel11
Copy link

schlegel11 commented Jul 16, 2018

Hmm I think currently there is no implementation which satisfy your case.
For me I would think there should be something similar to:

EventStreams.ticks(Duration.ofMinutes(MINUTES))

There is already the possibility to create a pasuable or suppressible stream but thats only related to the stream itself not to the ticks or whatever so the ticks can't be paused.

@JordanMartinez
Copy link
Contributor

Why not reimplement the FXTimer class with pause functionality in your own code base? It's using Timeline underneath, so you can use that class' pause method.

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

3 participants