mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-23 19:21:53 +03:00
Refactor slightly
This commit is contained in:
parent
424ea64182
commit
51aa73aaa8
@ -387,9 +387,7 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie
|
||||
)
|
||||
}
|
||||
)
|
||||
.andThen(
|
||||
self.api.sendResponse(msgid: msgid, error: .nil, result: .nil)
|
||||
)
|
||||
.andThen(self.api.sendResponse(.nilResponse(msgid)))
|
||||
.andThen(
|
||||
{
|
||||
let ginitPath = FileManager.default.homeDirectoryForCurrentUser
|
||||
|
@ -53,8 +53,8 @@ public final class RxNeovimApi {
|
||||
}
|
||||
}
|
||||
|
||||
public func sendResponse(msgid: UInt32, error: Value, result: Value) -> Completable {
|
||||
self.msgpackRpc.response(msgid: msgid, error: error, result: result)
|
||||
public func sendResponse(_ response: RxMsgpackRpc.Response) -> Completable {
|
||||
self.msgpackRpc.response(msgid: response.msgid, error: response.error, result: response.result)
|
||||
}
|
||||
|
||||
public init() {}
|
||||
|
@ -25,6 +25,10 @@ public final class RxMsgpackRpc {
|
||||
}
|
||||
|
||||
public struct Response {
|
||||
public static func nilResponse(_ msgid: UInt32) -> Self {
|
||||
return .init(msgid: msgid, error: .nil, result: .nil)
|
||||
}
|
||||
|
||||
public let msgid: UInt32
|
||||
public let error: Value
|
||||
public let result: Value
|
||||
@ -171,7 +175,7 @@ public final class RxMsgpackRpc {
|
||||
}
|
||||
|
||||
if !expectsReturnValue {
|
||||
single(.success(Response(msgid: msgid, error: .nil, result: .nil)))
|
||||
single(.success(.nilResponse(msgid)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,10 +204,6 @@ public final class RxMsgpackRpc {
|
||||
// Publish events only in streamQueue
|
||||
private let streamSubject = PublishSubject<Message>()
|
||||
|
||||
private func nilResponse(with msgid: UInt32) -> Response {
|
||||
Response(msgid: msgid, error: .nil, result: .nil)
|
||||
}
|
||||
|
||||
private func cleanUp() {
|
||||
self.queue.async { [weak self] in
|
||||
if self?.closed == true {
|
||||
@ -217,11 +217,7 @@ public final class RxMsgpackRpc {
|
||||
self?.errorPipe = nil
|
||||
|
||||
self?.streamSubject.onCompleted()
|
||||
self?.singles.forEach { msgid, single in single(.success(.init(
|
||||
msgid: msgid,
|
||||
error: .nil,
|
||||
result: .nil
|
||||
))) }
|
||||
self?.singles.forEach { msgid, single in single(.success(.nilResponse(msgid))) }
|
||||
|
||||
self?.log.info("RxMsgpackRpc closed")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user