Publishers.Encode
struct SimpleJSON: Encodable {
let key: String
}
let simpleJSON = SimpleJSON(key: "value")
// Publishers.Encode Publisher
Publishers.Encode(upstream: Just(simpleJSON), encoder: JSONEncoder())
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Encode Error")
case .finished:
print("Combine Encode Finish")
}
}, receiveValue: { value in
print("Combine Encode : \(value)")
})
.store(in: &cancellables)
// encode Operator
Just(simpleJSON)
.encode(encoder: JSONEncoder())
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Encode Error")
case .finished:
print("Combine Encode Finish")
}
}, receiveValue: { value in
print("Combine Encode : \(value)")
})
.store(in: &cancellables)
// Combine Encode : 15 bytes
// Combine Encode FinishRxSwift
ReactiveSwift
Last updated