Skip to content

Commit 141f1ce

Browse files
committed
Add support for rpc call options
1 parent de7f86d commit 141f1ce

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/vue-shv.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {computed, ComputedRef, onWatcherCleanup, Ref, ref, watchEffect} from 'vue';
2-
import {type WsClient, type WsClientOptionsLogin} from 'libshv-js/ws-client';
2+
import {CallRpcMethodOptions, type WsClient, type WsClientOptionsLogin} from 'libshv-js/ws-client';
33
import {useLocalStorage, useSessionStorage} from '@vueuse/core';
44
import PKCE from 'js-pkce';
55
import * as z from 'libshv-js-zod/zod';
@@ -200,13 +200,13 @@ export function useShv(options: VueShvOptions) {
200200
shvSessionStorage.value.shvLoginPassword = password;
201201
};
202202

203-
const rpcCall = async (shvPath: StringGetter, method: string, params?: RpcValue) => {
203+
const rpcCall = async (shvPath: StringGetter, method: string, params?: RpcValue, options?: CallRpcMethodOptions) => {
204204
const shv = await getConnection();
205-
return shv.callRpcMethod(await resolveString(shvPath), method, params);
205+
return shv.callRpcMethod(await resolveString(shvPath), method, params, options);
206206
};
207207

208-
const makeRpcCall = <ResultType>(shvPath: StringGetter, method: string, validator: z.ZodType<ResultType>) => async () => {
209-
const resultOrError = await rpcCall(await resolveString(shvPath), method);
208+
const makeRpcCall = <ResultType>(shvPath: StringGetter, method: string, validator: z.ZodType<ResultType>, options?: CallRpcMethodOptions) => async () => {
209+
const resultOrError = await rpcCall(await resolveString(shvPath), method, undefined, options);
210210
if (resultOrError instanceof Error) {
211211
return resultOrError;
212212
}
@@ -219,8 +219,9 @@ export function useShv(options: VueShvOptions) {
219219
return parsed.data;
220220
};
221221

222-
const makeRpcCallParam = <ResultType, ParamType extends RpcValue>(shvPath: StringGetter, method: string, _paramType: z.ZodType<ParamType>, validator: z.ZodType<ResultType>) => async (param: ParamType) => {
223-
const resultOrError = await rpcCall(await resolveString(shvPath), method, param);
222+
// eslint-disable-next-line max-params -- five is fine, this function does not get called a lot and I don't want to change everything to a config object
223+
const makeRpcCallParam = <ResultType, ParamType extends RpcValue>(shvPath: StringGetter, method: string, _paramType: z.ZodType<ParamType>, validator: z.ZodType<ResultType>, options?: CallRpcMethodOptions) => async (param: ParamType) => {
224+
const resultOrError = await rpcCall(await resolveString(shvPath), method, param, options);
224225
if (resultOrError instanceof Error) {
225226
return resultOrError;
226227
}

0 commit comments

Comments
 (0)