-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules.
Declaration
Swift
public func and<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), (B, C)>Parameters
thatSchedule to be composed with this one.
-
Composes this schedule with another one, providing a new schedule that needs the input of both schedules and provides the output of both. It continues as long as both continue, using the maximum delay of the two schedules.
Declaration
Swift
public func split<State2, C, D>(_ that: Schedule<R, C, State2, D>) -> Schedule<R, (A, C), (State, State2), (B, D)>Parameters
thatSchedule to be composed with this one.
-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules.
Declaration
Swift
public func zip<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), (B, C)>Parameters
thatSchedule to be composed with this one.
-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules, and ignoring the output of this schedule.
Declaration
Swift
public func zipRight<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), C>Parameters
thatSchedule to be composed with this one.
-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules, and ignoring the output of the provided schedule.
Declaration
Swift
public func zipLeft<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), B>Parameters
thatSchedule to be composed with this one.
-
Pipes the output of this schedule as the input of the provided one. Effects described by this schedule will always be performed before the effects described by the second schedule.
Declaration
Swift
public func pipe<State2, C>(_ that: Schedule<R, B, State2, C>) -> Schedule<R, A, (State, State2), C>Parameters
thatSchedule to be piped after this one.
-
Pipes the output of the provided schedule as the input of this schedule. Effects described by the provided schedule will always be performed before the effects described by this schedule.
Declaration
Swift
public func reversePipe<State2, C>(_ that: Schedule<R, C, State2, A>) -> Schedule<R, C, (State2, State), B>Parameters
thatSchedule to be piped before this one.
-
Composes with a schedule resulting in another one that continues as long as either schedule continues, using the minimum of the delays of the two schedules.
Declaration
Swift
public func or<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), (B, C)>Parameters
thatSchedule to be composed with this one.
-
Adds a delay of the specified duration based on the output of this schedule.
Declaration
Swift
public func addDelay(_ f: @escaping (B) -> DispatchTimeInterval) -> Schedule<R, A, State, B>Parameters
fFunction computing the delay time based on the output of the schedule.
-
Adds a delay of the specified duration based on the output of this schedule.
Declaration
Parameters
fAn effectful function that provides the delay time based on the output of the schedule.
-
Adds a delay of the specified duration based on the output of this schedule.
Declaration
Swift
public func addDelay(_ f: @escaping (B) -> TimeInterval) -> Schedule<R, A, State, B>Parameters
fFunction computing the delay time based on the output of the schedule.
-
Composes two schedules with the same input and output by applying them sequentially. It executes the first to completion, and then executes the second.
Declaration
Parameters
thatSchedule to be composed with this one.
-
Composes two schedules with the same input but different outputs by applying them sequentially. It executes the first to completion, and then executes the second.
Declaration
Parameters
thatSchedule to be composed with this one.
-
Transforms the output of this schedule to a fixed value.
Declaration
Swift
public func `as`<C>(_ c: C) -> Schedule<R, A, State, C>Parameters
cFixed value to return as output of this schedule.
-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules.
Declaration
Swift
public func both<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), (B, C)>Parameters
thatSchedule to be composed with this one.
-
Composes this schedule with another one, providing a new schedule that continues as long as both continue, using the maximum delay of the two schedules, and combining the outputs of both using the provided function.
Declaration
Swift
public func bothWith<State2, C, D>(_ that: Schedule<R, A, State2, C>, _ f: @escaping (B, C) -> D) -> Schedule<R, A, (State, State2), D>Parameters
thatSchedule to be composed with this one.
fTransforming function.
-
Peeks at the output produced by this schedule and executes a test to determine if the schedule should continue or not.
Declaration
Parameters
testEffectful predicate to determine if the schedule should continue or not based on the current input and output.
-
Collects all the output of this schedule in an array.
Declaration
Swift
public func collectAll() -> Schedule<R, A, (State, [B]), [B]> -
Pipes the output of the provided schedule as the input of this schedule. Effects described by the provided schedule will always be performed before the effects described by this schedule.
Declaration
Swift
public func compose<State2, C>(_ that: Schedule<R, C, State2, A>) -> Schedule<R, C, (State2, State), B>Parameters
thatSchedule to be piped before this one.
-
Provides an schedule that deals with a narrower class of inputs than this schedule.
Declaration
Swift
public func contramap<AA>(_ f: @escaping (AA) -> A) -> Schedule<R, AA, State, B>Parameters
fFunction transforming the input of this schedule.
-
Provides an schedule that contramaps the input and maps the output with the provided functions.
Declaration
Swift
public func dimap<AA, C>(_ f: @escaping (AA) -> A, _ g: @escaping (B) -> C) -> Schedule<R, AA, State, C>Parameters
fFunction to contramap.
gFunction to map.
-
Composes with a schedule resulting in another one that continues as long as either schedule continues, using the minimum of the delays of the two schedules.
Declaration
Swift
public func either<State2, C>(_ that: Schedule<R, A, State2, C>) -> Schedule<R, A, (State, State2), (B, C)>Parameters
thatSchedule to be composed with this one.
-
Composes with a schedule resulting in another one that continues as long as either schedule continues, using the minimum of the delays of the two schedules, and transforming the outputs with the provided function.
Declaration
Swift
public func eitherWith<State2, C, D>(_ that: Schedule<R, A, State2, C>, _ f: @escaping (B, C) -> D) -> Schedule<R, A, (State, State2), D>Parameters
thatSchedule to be composed with this one.
fTransforming function.
-
Provides a schedule that folds the outputs of this one.
Declaration
Swift
public func fold<Z>(_ z: Z, _ f: @escaping (Z, B) -> Z) -> Schedule<R, A, (State, Z), Z>Parameters
zInitial value for the folding process.
fFolding function.
-
Returns a new schedule that loops this one forever, resetting the state when this schedule is completed.
Declaration
Swift
public func forever() -> Schedule<R, A, State, B> -
Transforms the output of this schedule with the provided function.
Declaration
Swift
public func map<C>(_ f: @escaping (B) -> C) -> Schedule<R, A, State, C>Parameters
fTransforming function.
-
Provides a new schedule that emits the number of repetitions of this schedule.
Declaration
Swift
public func repetitions() -> Schedule<R, A, (State, Int), Int> -
Wipes out the output produced by this schedule.
Declaration
Swift
public func void() -> Schedule<R, A, State, Void> -
Provides a schedule that iterates this schedule until the input matches a given predicate.
Declaration
Swift
public func untilInput(_ f: @escaping (A) -> Bool) -> Schedule<R, A, State, B>Parameters
fPredicate to test the input of this schedule.
-
Provides a schedule that iterates this schedule until the output matches a given predicate.
Declaration
Swift
public func untilOutput(_ f: @escaping (B) -> Bool) -> Schedule<R, A, State, B>Parameters
fPredicate to test the output of this schedule.
-
Provides a schedule that iterates this schedule while the input matches a given predicate.
Declaration
Swift
public func whileInput(_ f: @escaping (A) -> Bool) -> Schedule<R, A, State, B>Parameters
fPredicate to test the input of this schedule.
-
Provides a schedule that iterates this schedule while the output matches a given predicate.
Declaration
Swift
public func whileOutput(_ f: @escaping (B) -> Bool) -> Schedule<R, A, State, B>Parameters
fPredicate to test the output of this schedule.
-
Provides a schedule that always recurs without delay and computes the output through subsequent applications of a function to an initial value.
Declaration
Swift
public static func unfold(_ a: B, _ f: @escaping (B) -> B) -> Schedule<R, A, B, B>Parameters
aInitial value.
fUnfolding function.
-
Provides a schedule that always recurs without delay and computes the output through subsequent applications of an effectful function to an initial value.
Declaration
Parameters
aInitial effect.
fUnfolding effectful function.
-
Provides a schedule that recurs forever without a delay, returning the elapsed time since it began.
Declaration
Swift
public static func elapsed() -> Schedule<R, A, (DispatchTime, DispatchTimeInterval), DispatchTimeInterval> -
Provides a schedule that recurs until the specified duration elapsed, returning the total elapsed time.
Declaration
Swift
public static func duration(_ interval: DispatchTimeInterval) -> Schedule<R, A, (DispatchTime, DispatchTimeInterval), DispatchTimeInterval>Parameters
intervalTime interval for this schedule to recur.
-
Provides a schedule that waits for the specified amount of time between each input. Returns the number of received inputs.
Declaration
Swift
public static func spaced(_ interval: DispatchTimeInterval) -> Schedule<R, A, State, Int>Parameters
intervalTime interval to wait between each action.
-
Provides a schedule that waits for the specified amount of time between each input. Returns the number of received inputs.
Declaration
Swift
public static func spaced(_ interval: TimeInterval) -> Schedule<R, A, State, Int>Parameters
intervalTime interval to wait between each action.
-
Provides a schedule that always recurs, waiting an amount of time between repetitions, given by an exponential backoff algorithm, and returning the current duration between recurrences.
The time to wait is given by the formula
base * pow(n + 1), wherenis the number of repetitions so far.Declaration
Swift
public static func exponential(_ base: DispatchTimeInterval, factor: Double = 2.0) -> Schedule<R, A, Int, TimeInterval>Parameters
baseBase time interval to wait between repetitions.
factorFactor for the exponential backoff. Defaults to 2.0.
-
Provides a schedule that always recurs, waiting an amount of time between repetitions, given by an exponential backoff algorithm, and returning the current duration between recurrences.
The time to wait is given by the formula
base * pow(n + 1), wherenis the number of repetitions so far.Declaration
Swift
public static func exponential(_ base: TimeInterval, factor: Double = 2.0) -> Schedule<R, A, Int, TimeInterval>Parameters
baseBase time interval to wait between repetitions.
factorFactor for the exponential backoff. Defaults to 2.0.
-
Provides a schedule that always recurs, waiting an amount of time between repetitions, given by a linear backoff algorithm, and returning the current duration between recurrences.
The time to wait is given by the formula
base * (n + 1), wherenis the number of repetitions so far.Declaration
Swift
public static func linear(_ base: DispatchTimeInterval) -> Schedule<R, A, Int, TimeInterval>Parameters
baseBase time interval to wait between repetitions.
-
Provides a schedule that always recurs, waiting an amount of time between repetitions, given by a linear backoff algorithm, and returning the current duration between recurrences.
The time to wait is given by the formula
base * (n + 1), wherenis the number of repetitions so far.Declaration
Swift
public static func linear(_ base: TimeInterval) -> Schedule<R, A, Int, TimeInterval>Parameters
baseBase time interval to wait between repetitions.
-
Provides a schedule that always recurs, increasing delays by summing the preceding two delays, as in the Fibonacci sequence. Returns the current duration between recurrences.
Declaration
Swift
public static func fibonacci(_ one: DispatchTimeInterval) -> Schedule<R, A, (TimeInterval, TimeInterval), TimeInterval>Parameters
oneTime interval for the initial delay.
-
Provides a schedule that always recurs, increasing delays by summing the preceding two delays, as in the Fibonacci sequence. Returns the current duration between recurrences.
Declaration
Swift
public static func fibonacci(_ one: TimeInterval) -> Schedule<R, A, (TimeInterval, TimeInterval), TimeInterval>Parameters
oneTime interval for the initial delay.
-
Provides a schedule that wipes out the output.
Declaration
Swift
public static func void() -> Schedule<R, A, Unit, Void>
-
Provides a schedule that returns the input, unmodified.
Declaration
Swift
public static func identity() -> Schedule<R, A, Unit, A> -
Provides a schedule that recurs as long as the predicate evaluates to true.
Declaration
Swift
public static func doWhile(_ f: @escaping (A) -> Bool) -> Schedule<R, A, Unit, A>Parameters
fPredicate to test the input.
-
Provides a schedule that recurs until the predicate evaluates to true.
Declaration
Swift
public static func doUntil(_ f: @escaping (A) -> Bool) -> Schedule<R, A, Unit, A>Parameters
fPredicate to test the input.
-
Provides a schedule that recurs forever, mapping input values through the provided function.
Declaration
Swift
public static func from(function: @escaping (A) -> B) -> Schedule<R, A, State, B>Parameters
functionTransforming function.
-
Provides a schedule that recurs as long as the input is equal to a specific value.
Declaration
Swift
public static func doWhileEquals(_ a: A) -> Schedule<R, A, Unit, A>Parameters
aValue to compare the input of the schedule.
-
Provides a schedule that recurs as long as the input is not equal to a specific value.
Declaration
Swift
public static func doUntilEquals(_ a: A) -> Schedule<R, A, Unit, A>Parameters
aValue to compare the input of the schedule.
-
Provides a schedule that runs forever and emits the number of iterations it has performed.
Declaration
Swift
public static func forever() -> Schedule<R, A, Int, Int> -
Provides a schedule that recurs a specific number of times, emitting the current iteration it is in.
Declaration
Swift
public static func recurs(_ n: Int) -> Schedule<R, A, Int, Int>Parameters
nNumber of iterations to perform.
-
Provides a schedule that recurs only once.
Declaration
Swift
public static func once() -> Schedule<R, A, Int, Void> -
Provides a schedule that recurs zero times.
Declaration
Swift
public static func stop() -> Schedule<R, A, Int, Void>
-
Provides a schedule that never recurs.
Declaration
Swift
public static func never() -> Schedule<R, Any, Never, Never>
-
Provides a schedule that recurs forever and collects all its outputs in an array.
Declaration
Swift
public static func collectAll() -> Schedule<R, A, State, [A]> -
Provides a schedule that collects its outputs in an array as long as the outputs match a given predicate.
Declaration
Swift
public static func collectWhile(_ f: @escaping (A) -> Bool) -> Schedule<R, A, State, [A]>Parameters
fPredicate to test the outputs.
-
Provides a schedule that collects its outputs in an array until an output matches a given predicate.
Declaration
Swift
public static func collectUntil(_ f: @escaping (A) -> Bool) -> Schedule<R, A, State, [A]>Parameters
fPredicate to test the outputs.
Install in Dash
Schedule Class Reference