You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ReactiveTask is a Swift framework for launching shell tasks (processes), built using ReactiveSwift.
letstrings=["foo\n","bar\n","buzz\n","fuzz\n"]letinput=SignalProducer<Data,NoError>(values: strings.map{ $0.data(using:.utf8)! })lettask=Task("/usr/bin/sort")
// Run the task, ignoring the output, and do something with the final result.
letresult:Result<String,TaskError>?= task.launch(standardInput: input).ignoreTaskData().map{String(data: $0, encoding:.utf8)}.ignoreNil().single()print("Output of `\(task)`: \(result?.value ??"")")
// Start the task and print all the events, which includes all the output
// that was received.
task.launch(standardInput: input).flatMapTaskEvents(.concat){ data inreturnSignalProducer(value:String(data: data, encoding:.utf8))}.startWithNext{(event:TaskEvent)inswitch event {caselet.launch(task):print("launched task: \(task)")caselet.standardError(data):print("stderr: \(data)")caselet.standardOutput(data):print("stdout: \(data)")caselet.success(string):print("value: \(string ??"")")}}
For examples of how to use ReactiveTask, see the Xcode and Git integration code from the CarthageKit framework.