module A very early concept of implementing functional reactive programming. Currently only used to provide mutability.
- enum Async
- extern Future
- extern Variable
- func await async
- func catch transform
- func flatMap transform
- func flatten async
- func map transform
- func onSuccess sideEffect
enum
extern Represents a value calculated in background. It will arrive some time in the future.
import results
import rx
let future = rx.Future { receive =>
// will be performed in background
receive results.Success 42
}
// the .await will block and wait for the result
with future.await, type results.Result {
Success: { value => value },
Failure: { err =>
print err
0 // as default
},
}
await
- Waits for the future to complete. This will lock the current function until the result has arrived. At the end, returns theresults.Result
.
extern Holds a value and enables replacing it. Planned to propagate value changes to observers, but not implemented, yet.
accept value
- Changes the currently hold value of the variable.current
- Returns the currently hold value.
func await async
func catch transform
func flatMap transform
func flatten async
func map transform
func onSuccess sideEffect