MotionRuntime.whenAllAtRest specification
This is the engineering specification for the MotionRuntime
’s whenAllAtRest
API.
Overview
whenAllAtRest invokes a callback once all of the provided Stateful
interactions have come to rest.
If the provided list of interactions is empty, then the callback is invoked exactly once and immediately.
If all of the interactions are at rest then the callback is invoked before returning.
Example:
runtime.whenAllAtRest([directlyManipulable]) {
print("Is now at rest")
}
MVP
Expose a whenAllAtRest API
Accept an array of Stateful
interactions and a callback function.
class MotionRuntime {
public func whenAllAtRest(_ interactions: [Stateful], body: () -> Void)
}
When no interactions are provided, invoke the callback immediately
func whenAllAtRest(_ interactions: [Stateful], body: () -> Void) {
guard interactions.count > 0 else {
body()
return
}
}