This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output(.radio(.visualizer( .activation(.succeeded)))) | |
output(.radio(.visualizer(.deactivation(.succeeded)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request(player, to:.play(station)) | |
request(player, to:.pause) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Player: UseCase { | |
enum Request { | |
case play(Station) | |
case pause | |
} | |
enum Response { | |
case playing(String, on:Station) | |
case paused (Station) | |
case waiting(Station) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol UseCase { | |
associatedtype RequestType | |
associatedtype ResponseType | |
func request(to request:RequestType) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createRadioFeature( | |
store s: Store, | |
player p: AudioPlayer, | |
output o: @escaping Output) -> Input | |
{ | |
let loader = StationLoader( store:s, responder:handle(output:o)) | |
let player = Player(audioplayer:p, store:s, responder:handle(output:o)) | |
let visActivater = VisualisationActivator( store:s, responder:handle(output:o)) | |
let visualiser = Visualiser(audioplayer:p, store:s, responder:handle(output:o)) | |
let filter = StationFilter( store:s, responder:handle(output:o)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias Input = (Message) -> () | |
typealias Output = (Message) -> () | |
func createRadioFeature( | |
store s: Store, | |
player p: AudioPlayer, | |
output o: @escaping Output | |
) -> Input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:_Stack<String> = createStack() | |
s.push("one") | |
s.push("two") | |
s.push("three") | |
let o = Stack(s) | |
o.push("four") | |
let t = Stack.Transcoder(stack: o) | |
let jsonData = try! JSONEncoder().encode(t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Stack { | |
struct Transcoder: Codable { | |
enum CodingKeys: String, CodingKey { case elements } | |
let stack: Stack<T> | |
init(stack s:Stack<T>) { stack = s } | |
init(from decoder: Decoder) throws { | |
stack = Stack(createStack(with:try decoder.container(keyedBy:CodingKeys.self).decode(Array<T>.self,forKey:.elements))) | |
} | |
func encode(to encoder: Encoder) throws { | |
var container = encoder.container(keyedBy: CodingKeys.self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Stack<String>: 4 elements --- | |
"four" | |
"three" | |
"two" | |
"one" | |
+++++++++++++++++++++++++++++++++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let o = Stack(s) | |
o.push("four") | |
print(o) |