-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c39ce6
commit 9304c2c
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
15 changes: 15 additions & 0 deletions
15
NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"originHash" : "1d2e6911b0388532b33f83466feee8deadacbc6241719180eb45fd871a5091ac", | ||
"pins" : [ | ||
{ | ||
"identity" : "coreevents", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/surfstudio/CoreEvents", | ||
"state" : { | ||
"revision" : "35ea2dac82e61d7fa1fab1b10e0038d31ff3fd53", | ||
"version" : "2.0.2" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
42 changes: 42 additions & 0 deletions
42
NodeKit/Layers/InputProcessingLayer/EntryInputDtoOutputNode.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// EntryinputDtoOutputNode.swift | ||
// CoreNetKit | ||
// | ||
// Created by Александр Кравченков on 15/04/2019. | ||
// Copyright © 2019 Кравченков Александр. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
open class EntryInputDtoOutputNode<Input, Output>: AsyncNode | ||
where Input: RawEncodable, Output: DTODecodable { | ||
|
||
open var next: any AsyncNode<Input.Raw, Output.DTO.Raw> | ||
|
||
init(next: any AsyncNode<Input.Raw, Output.DTO.Raw>) { | ||
self.next = next | ||
} | ||
|
||
open func processLegacy(_ data: Input) -> Observer<Output> { | ||
do { | ||
let raw = try data.toRaw() | ||
return self.next.processLegacy(raw).map { try Output.from(dto: Output.DTO.from(raw: $0) ) } | ||
} catch { | ||
return .emit(error: error) | ||
} | ||
} | ||
|
||
open func process( | ||
_ data: Input, | ||
logContext: LoggingContextProtocol | ||
) async -> NodeResult<Output> { | ||
return await .withMappedExceptions { | ||
let raw = try data.toRaw() | ||
return try await next.process(raw, logContext: logContext).map { | ||
let dto = try Output.DTO.from(raw: $0) | ||
return try Output.from(dto: dto) | ||
} | ||
} | ||
} | ||
|
||
} |