Class AsyncContainer
java.lang.Object
org.apache.sling.scripting.sightly.js.impl.async.AsyncContainer
Simple container for asynchronously provided values
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(UnaryCallback unaryCallback) Add a listener that will receive the value in this container when it will be filled.void
Complete this async container with a valueCreate a callback that will complete this containerGet the result of this holderboolean
Check whether the container was completed with a value
-
Constructor Details
-
AsyncContainer
public AsyncContainer()
-
-
Method Details
-
addListener
Add a listener that will receive the value in this container when it will be filled. If the container already has a value, the callback is called immediately.- Parameters:
unaryCallback
- the callback that will receive the result
-
getResult
Get the result of this holder- Returns:
- the holder result
- Throws:
NoSuchElementException
- if the result has not yet been set
-
isCompleted
public boolean isCompleted()Check whether the container was completed with a value- Returns:
- the completion status
-
complete
Complete this async container with a value- Parameters:
value
- the result value- Throws:
IllegalStateException
- if the container has been previously filled
-
createCompletionCallback
Create a callback that will complete this container- Returns:
- the completion callback
-