Task
final class Task
Package: dev.joid.lib.ui.task · Module: core · Source: Task.java
Code that runs once after a delay, or on a period, while it is attached to a UI or a node.
Description
Section titled “Description”Runs its listeners on the render thread while its UI or its node is drawn (Know how long a task lives).
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
Task | create(long delay) factory | Creates a task that runs once, this many ms after it is attached. |
Methods
Section titled “Methods”Children
Section titled “Children”| Returns | Signature | Summary |
|---|---|---|
this | attach(UI ui) fluent | Attaches the task to the UI and starts counting its delay; it leaves its previous owner first. |
this | attach(Node node) fluent | Attaches the task to the node and starts counting its delay. |
this | detach() fluent | Detaches the task, which stops running. |
boolean | isAttached() | If true, the task has a UI or a node. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
boolean | isDue() | If true, the task is attached and its next run time has come. |
long | getDelay() | Time, in ms, between the attach and the first run. |
EventBus | getEventBus() | The listeners of the task. |
long | getPeriod() | Time, in ms, between two runs; negative for a task that runs once. |
long | getNextRun() | Time of the next run, in nanoseconds of the clock bridge (nanoTime()). |
UI | getUi() | The UI the task is attached to, or null. |
Node | getNode() | The node the task is attached to, or null. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
this | every(long period) fluent | Makes the task run again every period ms after its first run, until it is detached. |
this | owner(UI ui, Node node) fluent | Records the owner of the task and, when it has one, starts counting its delay. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | fireRun() | Runs the listeners now and plans the next run, or detaches a one-shot task. |
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onRun | EventListener<TaskEvent> | Adds a listener that runs each time the task runs. |
Creation details
Section titled “Creation details”create
Section titled “create”Task create(long delay) factory
Creates a task that runs once, this many ms after it is attached.
Method details
Section titled “Method details”attach
Section titled “attach”this attach(UI ui) fluent
Attaches the task to the UI and starts counting its delay; it leaves its previous owner first.
this attach(Node node) fluent
Attaches the task to the node and starts counting its delay.
detach
Section titled “detach”this detach() fluent
Detaches the task, which stops running.
isAttached
Section titled “isAttached”boolean isAttached()
If true, the task has a UI or a node.
boolean isDue()
If true, the task is attached and its next run time has come.
getDelay
Section titled “getDelay”long getDelay()
Time, in ms, between the attach and the first run.
getEventBus
Section titled “getEventBus”EventBus getEventBus()
The listeners of the task.
getPeriod
Section titled “getPeriod”long getPeriod()
Time, in ms, between two runs; negative for a task that runs once.
getNextRun
Section titled “getNextRun”long getNextRun()
Time of the next run, in nanoseconds of the clock bridge (nanoTime()).
UI getUi()
The UI the task is attached to, or null.
getNode
Section titled “getNode”Node getNode()
The node the task is attached to, or null.
this every(long period) fluent
Makes the task run again every period ms after its first run, until it is detached.
this owner(UI ui, Node node) fluent
Records the owner of the task and, when it has one, starts counting its delay.
UI.addTask and Node.addTask call it; you attach with attach.
fireRun
Section titled “fireRun”void fireRun()
Runs the listeners now and plans the next run, or detaches a one-shot task. The UI calls it when the task is due.
Event details
Section titled “Event details”this onRun(EventListener<TaskEvent> listener) fluent
Adds a listener that runs each time the task runs.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
