@mateosuarezdev/brpc 1.0.85 → 1.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{useCallback as B,useEffect as D,useRef as F}from"react";function I(q,w,x={}){let m=F(null);return D(()=>{if(x.enabled===!1){m.current=null;return}let{publish:j,unsubscribe:z}=q(w??((y,A)=>{if(y){console.error("BRPC subscription error:",y);return}console.log("New data received",A)}),x);return m.current=j,()=>{m.current=null,z()}},[q,w,x]),{publish:B((j)=>{m.current?.(j)},[])}}export{I as useSubscription};
2
+ import{useCallback as z,useEffect as A,useRef as B}from"react";function G(q,w,x={}){let m=B(null);return A(()=>{if(x.enabled===!1){m.current=null;return}let{publish:j,unsubscribe:y}=q(w,x);return m.current=j,()=>{m.current=null,y()}},[q,w,x]),{publish:z((j)=>{m.current?.(j)},[])}}export{G as useSubscription};
3
3
 
4
- //# debugId=DBE7A95679FC784164756E2164756E21
4
+ //# debugId=6133CE2488D75E1D64756E2164756E21
@@ -5,10 +5,9 @@ export type UseSubscriptionOptions = RuntimeSubscriptionOptions & {
5
5
  /**
6
6
  * Connects React state to a BRPC subscription.
7
7
  */
8
- declare function useSubscription<TInput, TOutput>(subscription: (callback: SubscriptionCallback<TOutput>, options?: RuntimeSubscriptionOptions) => {
8
+ export declare function useSubscription<TInput, TOutput>(subscription: (callback: SubscriptionCallback<TOutput>, options?: RuntimeSubscriptionOptions) => {
9
9
  publish: (data: TInput) => void;
10
10
  unsubscribe: () => void;
11
- }, callback?: SubscriptionCallback<TOutput>, options?: UseSubscriptionOptions): {
11
+ }, callback: SubscriptionCallback<TOutput>, options?: UseSubscriptionOptions): {
12
12
  publish: (data: TInput) => void;
13
13
  };
14
- export { useSubscription };
@@ -15,7 +15,7 @@ export type InferRouterOutput<T> = {
15
15
  [K in keyof T]: T[K] extends BaseProcedure ? InferProcedureOutput<T[K]> : T[K] extends Record<string, any> ? InferRouterOutput<T[K]> : never;
16
16
  };
17
17
  export type IsOptionalInput<T> = undefined extends InferProcedureInput<T> ? true : {} extends InferProcedureInput<T> & {} ? true : false;
18
- export type SubscriptionCallback<T> = (error: BrpcClientSubscriptionError | undefined, message?: T) => void;
18
+ export type SubscriptionCallback<T> = (...args: [error: BrpcClientSubscriptionError] | [error: undefined, message: T]) => void;
19
19
  type RouteParamValue = string | number | boolean;
20
20
  type EmptyRouteParams = Record<never, never>;
21
21
  export type RouteParams = Record<string, RouteParamValue>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mateosuarezdev/brpc",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "description": "A Type-Safe, Flexible Web application framework for Bun",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",