TaskExtensions
Task Extensions. Import extensions for more flexibility in building tasks.
Attributes
- Example
-
import portals.api.builder.TaskExtensions.* // imported filter TaskExtension TaskBuilder.filter[Int]( event => event > 0 )
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TaskExtensions.type
Members list
Type members
Classlikes
Behavior factories for VSM Tasks.
Behavior factories for VSM Tasks.
A VSMTask is a task that can be in one of several states. A state is a VSMTask instance. The methods of the VSMTask return the next VSMTask behavior to execute.
The VSM Tasks are used in a context with using the surrounding TaskBuilder.vsm
behavior.
Attributes
- See also
-
VSMTask
TaskBuilder.vsm
wrapping initializing behavior. - Example
-
val init = VSMExtension.processor { event => started } val started = VSMExtension.processor { event => init } val vsm = TaskBuilder.vsm[Int, Int] { init }
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
VSMTasks.type
Experimental classlikes
Attributes
- Experimental
- true
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
StashExtension.type
Extensions
Extensions
Filter events using the predicate p
.
Filter events using the predicate p
.
Attributes
Behavior factory for flatMap.
Behavior factory for flatMap.
Map and flatten events of type T
to events of type U
.
Type parameters
- T
-
type of the input events
- U
-
type of the output events
Value parameters
- f
-
the flatMap function
Attributes
- Returns
-
the flatMap task
- Example
-
TaskBuilder.flatMap[String, Int]( event => event.split(" ") )
Log all events with the optional prefix
.
Log all events with the optional prefix
.
Attributes
Vsm behavior factory
Vsm behavior factory
The inner behavior should return the next state, for this we recommend the use of [VSMExtension.processor], note that the use of Tasks.processor
will not work, as it returns Unit
and not the next behavior. Warning: do not use vsm for the inner behavior, this will lead to an infinite loop and crash.
Example:
val init = VSMExtension.processor { event => started }
val started = VSMExtension.processor { event => init }
val vsm = VSMExtension.vsm[Int, Int] { init }
Attributes
Replace the onAtomComplete method of the task by f
.
Replace the onAtomComplete method of the task by f
.
Attributes
Replace the onComplete method of the task by f
.
Replace the onComplete method of the task by f
.
Attributes
Replace the onError method of the task by f
.
Replace the onError method of the task by f
.
Attributes
Replace the onNext method of the task by f
.
Replace the onNext method of the task by f
.
Attributes
Behavior factory for looping behaviors over atoms. This will execute the provided _task
for the following count
atoms.
Behavior factory for looping behaviors over atoms. This will execute the provided _task
for the following count
atoms.
Value parameters
- _task
-
the task to execute for the next
count
atoms - count
-
the number of loops/atoms to execute the
_task
for
Attributes
- Returns
-
a looping task executing first the previous
task
and then_task
forcount
iterations - Example
-
val task = TaskBuilder .map[String, String]{ event => event } .withLoop(2)(TaskBuilder.map[String, String]{ event => event.reverse })
Behavior factory for taking steps over atoms. This will execute the provided _task
for the following atom subsequently to the current task
.
Behavior factory for taking steps over atoms. This will execute the provided _task
for the following atom subsequently to the current task
.
Value parameters
- _task
-
the task to execute for the next atom
Attributes
- Returns
-
a stepping task executing first the prvious
task
and then_task
- Example
-
val task = TaskBuilder .map[String, String]{ event => event } .withStep(TaskBuilder.map[String, String]{ event => event.reverse })
Chain a task with another _task
, the tasks will share state.
Chain a task with another _task
, the tasks will share state.
Type parameters
- TT
-
the type of the output of the chained
_task
Value parameters
- _task
-
the task to execute after the current
task
Attributes
- Returns
-
a task executing first the previous
task
and then_task
- Example
-
val task = TaskBuilder .map[String, String]{ event => event } .withAndThen(TaskBuilder.map[String, String]{ event => event.reverse })
Wrapping around the behavior of a task. The wrapped behavior is accessible for use.
Wrapping around the behavior of a task. The wrapped behavior is accessible for use.
Example use:
Tasks.map[Int, Int] { _ + 5 }
.withWrapper[String]{ ctx ?=> wrapped => event =>
if event < 3 then ctx.emit("0") else wrapped(event)
}
Type parameters
- V
-
additional type for widening the output type of the task by union
Value parameters
- f
-
the wrapping function to wrap around the behavior of the task
Attributes
- Returns
-
a task with the wrapped behavior