trait AsyncAction[A, P <: AsyncAction[A, P]] extends Action
Base trait for asynchronous actions. Provides support for handling of multi-state actions. Implementation classes
must implement result, next and state functions. If you are using Pot, consider using PotAction instead.
Example:
case class MyAction( state: PotState = PotState.PotEmpty, result: Try[String] = Failure(new AsyncAction.PendingException)) extends AsyncAction[Int, MyAction] { def next(newState: PotState, newValue: Try[String]) = MyAction(newState, newValue) }
- A
Type of action result
- P
Type of the actual action class
- Alphabetic
- By Inheritance
- AsyncAction
- Action
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
next(newState: PotState, newValue: Try[A]): P
Moves the action to the next state.
Moves the action to the next state.
- newState
New state for the action
- newValue
New value for the action
- returns
A new instance of this action with updated state and value
- abstract def result: Try[A]
- abstract def state: PotState
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
effect[B](f: ⇒ Future[B])(success: (B) ⇒ A, failure: (Throwable) ⇒ Throwable = identity)(implicit ec: ExecutionContext): EffectSingle[P]
Wraps a by-name future result into an effect using success and failure transformations.
Wraps a by-name future result into an effect using success and failure transformations.
- f
Future to wrap, passes using by-name (lazy evaluation)
- success
Transformation function for success case
- failure
Transformation function for failure case
- returns
An
Effectfor running the providedFuture
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
failed(ex: Throwable): P
Moves this action to a failed state with the provided exception.
Moves this action to a failed state with the provided exception.
- ex
Reason for the failure.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
handle[M](pf: PartialFunction[PotState, ActionResult[M]]): ActionResult[M]
Handles the action using the supplied partial function matching current state.
-
def
handleWith[M, T](handler: ActionHandler[M, T], effect: Effect)(f: (AsyncAction.this.type, ActionHandler[M, T], Effect) ⇒ ActionResult[M]): ActionResult[M]
Handles the action using an external handler function.
Handles the action using an external handler function. The function is provided with instance of this
AsyncAction, theActionHandlerthis action currently resides in and the provided updateEffect.- handler
The current action handler instance.
- effect
Effect that performs the requested async operation.
- f
External handler function
- returns
An action result
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
pending: P
Moves this action to pending state.
-
def
ready(a: A): P
Moves this action to ready state with a result value.
Moves this action to ready state with a result value.
- a
Result for the action.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- implicit object PActionType extends ActionType[P]