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
a7d130ab95
commit
c9325dcd89
File diff suppressed because it is too large
Load Diff
@ -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) }
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
''')
|
||||
|
Loading…
Reference in New Issue
Block a user