why useEventCallback's inputs$ and states$ opposite to their input argument order
maple-leaf opened this issue · 5 comments
const [onEvent] = useEventCallback((events$, x$, y$) => {
x$.subscribe(x => console.log('x ', x)) // log: x [false]
y$.subscribe(y => console.log('y ', y)) // log: y [0]
}, [0], [false]);I thinks x to be 0 and y to be false is expected, but useEventCallback give opposite result. Am I doing something wrong.
versions info:
rxjs-hooks: 0.4.3
I am a bit confused.
https://github.com/LeetCode-OpenSource/rxjs-hooks/blame/master/README.md#L338
https://github.com/LeetCode-OpenSource/rxjs-hooks/blame/master/README.md#L217
These two signatures are not the same right?
Oh I see. It is reversed in EventCallback.
https://github.com/LeetCode-OpenSource/rxjs-hooks/blame/master/README.md#L203-L207
But if I write something like this the EventValue generic of useEventCallback gets resolved to unknown. How to fix it?
const [onChange] = useEventCallback(
(event$: Observable<React.MouseEvent<HTMLDivElement>>, $input) =>
event$.pipe(
map(e => e.type === 'mouseenter'),
debounceTime(300),
withLatestFrom($input),
tap(([type , [onChange]]) => onChange(type))
),
false,
[props.onChange]
)@Brooooooklyn I would like to PR this, however it would be a breaking change as the order should be reversed for each call that uses the 3 observables
Edit: Add PR link
PR link: Reverse EventCallback state$ and inputs$ order