1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-23 19:21:53 +03:00

Refactor slightly

This commit is contained in:
Tae Won Ha 2023-12-23 21:17:37 +01:00
parent a7d130ab95
commit c9325dcd89
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 261 additions and 262 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,13 +40,12 @@ public final class RxNeovimApi {
public func stop() -> Completable { self.msgpackRpc.stop() }
public func rpc(
public func sendRequest(
method: String,
params: [RxNeovimApi.Value],
expectsReturnValue: Bool = true
params: [RxNeovimApi.Value]
) -> Single<RxNeovimApi.Value> {
self.msgpackRpc
.request(method: method, params: params, expectsReturnValue: expectsReturnValue)
.request(method: method, params: params, expectsReturnValue: true)
.map { response -> RxMsgpackRpc.Value in
guard response.error.isNil else { throw RxNeovimApi.Error(response.error) }

View File

@ -18,7 +18,7 @@ void_func_template = Template('''\
]
return self
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
.sendRequest(method: "${nvim_func_name}", params: params)
.asCompletable()
}
''')
@ -30,7 +30,7 @@ get_mode_func_template = Template('''\
${params}
]
return self
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
.sendRequest(method: "${nvim_func_name}", params: params)
.map { value in
guard let result = (${return_value}) else {
throw RxNeovimApi.Error.conversion(type: ${result_type}.self)
@ -57,7 +57,7 @@ func_template = Template('''\
}
return self
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
.sendRequest(method: "${nvim_func_name}", params: params)
.map(transform)
}
''')