public class Counter extends Object
The counter class will allow the user to make a counting trigger that starts from a starting value to an end value. the increments are controlled with a time interval and the user will be notified through a handler everytime the count it changed
e.g : count from 0 to 100 by 1 increment every 1 second and log the count to the console
Counter
.countFrom(0)
.countTo(100)
.every(1000)
.incrementBy(1)
.onCount(count -> DomGlobal.console.info(count))
.startCounting();
| Modifier and Type | Class and Description |
|---|---|
static interface |
Counter.CanCountTo
An interface to provide the counter end value
|
static class |
Counter.CounterBuilder
A fluent builder to force building a counter with required parameters
|
static interface |
Counter.CountHandler
An interface to define a handler to be called after each count
|
static interface |
Counter.HasCountHandler
An interface to set the count handler
|
static interface |
Counter.HasIncrement
An interface to set the counter increment
|
static interface |
Counter.HasInterval
An interface to set the counter count interval
|
| Modifier and Type | Method and Description |
|---|---|
static Counter.CanCountTo |
countFrom(int countFrom)
static factory to create a new counter instance with count start
|
void |
startCounting()
Starts the counter, if the counter is already counting it will reset and start counting from
the beginning
|
public static Counter.CanCountTo countFrom(int countFrom)
countFrom - intCounter.CanCountTopublic void startCounting()
Copyright © 2019–2022 Dominokit. All rights reserved.