@@ -24,27 +24,27 @@ export function usePreviousIfDeeplyEqual<T>(val: T) {
2424}
2525
2626/**
27- * Calls method `setter ` on `box` with `value`, iff `value` is set & deeply
27+ * Calls method `method ` on `box` with `value`, iff `value` is set & deeply
2828 * different from before (and the box is alive)
2929 */
30- export function useSetter <
30+ export function useMethod <
3131 V ,
3232 S extends string ,
3333 T extends TalkObject & Record < S , ( val : V ) => any > ,
34- > ( box : T | undefined , value : V | undefined , setter : S ) {
34+ > ( box : T | undefined , value : V | undefined , method : S ) {
3535 value = usePreviousIfDeeplyEqual ( value ) ;
3636 useEffect ( ( ) => {
3737 if ( value !== undefined && box ?. isAlive ) {
38- box [ setter ] ( value ) ;
38+ box [ method ] ( value ) ;
3939 }
40- } , [ setter , box , value ] ) ;
40+ } , [ method , box , value ] ) ;
4141}
4242
4343/**
44- * Calls method `setter` on `box` with the arguments `args`, iff `args` is set &
45- * deeply different from before (and the box is alive)
44+ * Like { @link useMethod}, except `args` is an array that gets spread into
45+ * the method call
4646 */
47- export function useSpreadSetter <
47+ export function useSpreadMethod <
4848 V extends any [ ] ,
4949 S extends string ,
5050 T extends TalkObject & Record < S , ( ...args : V ) => any > ,
@@ -77,10 +77,10 @@ export function useConversation<T extends Talk.UIBox>(
7777 } , [ session , syncConversation , conversationId ] ) ;
7878
7979 const args = (
80- conversation !== undefined ? [ conversation , { asGuest } ] : [ ]
80+ conversation !== undefined ? [ conversation , { asGuest } ] : undefined
8181 ) as any ;
8282
83- useSpreadSetter ( box , args , "select" ) ;
83+ useSpreadMethod ( box , args , "select" ) ;
8484}
8585
8686// subset of Session to help TypeScript pick the right overloads
0 commit comments