Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: IOTask

[16:7] extends: FxObj

Wraps FXGL's IOTask, the dominant async primitive across fxgl-io and the OSService / UpdaterService. Every file system, save/load, networking, and process API returns an IOTask. Aussom users attach onSuccess, onFailure, and onCancel callbacks then call run (which executes synchronously on the calling thread) or hand the task to IOTaskExecutorService.runAsyncFX for off-thread execution that marshals results back to the FX thread.

Methods

  • IOTask (Ajo = null)

    Wraps an existing IOTask AussomJavaObject in an IOTask wrapper. Use this when an FXGL method returns a raw IOTask via AJI.

    • @p Ajo is an AussomJavaObject around an FXGL IOTask.
  • of (callback Action)

    Creates a new IOTask that runs the given callable on run.

    • @p Action is a callback returning the task result.
    • @r A new IOTask wrapper.
  • ofVoid (callback Action)

    Creates a new void IOTask that runs the given Runnable on run.

    • @p Action is a callback that returns no value.
    • @r A new IOTask wrapper.
  • onSuccess (callback Cb)

    Registers a callback that runs with the task result if the task succeeds.

    • @p Cb is a callback taking the result as its argument.
    • @r this object
  • onFailure (callback Cb)

    Registers a callback that runs with a Throwable if the task fails.

    • @p Cb is a callback taking the throwable as its argument.
    • @r this object
  • onCancel (callback Cb)

    Registers a callback that runs (with no arguments) if the task is cancelled.

    • @p Cb is a callback taking no arguments.
    • @r this object
  • cancel ()

    Marks the task as cancelled. Tasks that respect cancellation will stop and invoke the onCancel handler.

    • @r this object
  • isCancelled ()

    Returns whether cancel was previously invoked on this task.

    • @r A bool.
  • getName ()

    Returns this task's name string. Useful for diagnostics.

    • @r A string.
  • run ()

    Runs the task synchronously on the calling thread, dispatching onSuccess or onFailure inline. Returns the task result (or null for ofVoid tasks).

    • @r The task result.
  • then (callback Mapper)

    Chains a continuation that maps this task's result through a function returning another IOTask.

    • @p Mapper is a callback taking the result and returning an IOTask wrapper or AussomJavaObject.
    • @r A new IOTask wrapper representing the chained task.
  • thenWrap (callback Mapper)

    Chains a continuation that maps this task's result through a function returning a plain value (wrapped in an IOTask).

    • @p Mapper is a callback taking the result and returning a new value.
    • @r A new IOTask wrapper.
  • ofNamed (string Name, callback Action)

    Same as of(action) but assigns a name to the task for diagnostics.

    • @p Name is the task name.
    • @p Action is a callback returning the task result.
    • @r A new IOTask wrapper.
  • ofVoidNamed (string Name, callback Action)

    Same as ofVoid(action) but assigns a name to the task.

    • @p Name is the task name.
    • @p Action is a callback that returns no value.
    • @r A new IOTask wrapper.
  • toJavaFXTask ()

    Returns this task as a javafx.concurrent.Task, suitable for binding to a progress UI.

    • @r An AussomJavaObject around a javafx.concurrent.Task.
  • hasFailAction ()

    Returns true when this task has an onFailure handler installed.