Skip to content

why useEventCallback's inputs$ and states$ opposite to their input argument order #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maple-leaf opened this issue Jun 20, 2019 · 5 comments
Labels
good first issue Good for newcomers

Comments

@maple-leaf
Copy link

  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

@Brooooooklyn Brooooooklyn added the good first issue Good for newcomers label Jun 25, 2019
@crimx
Copy link

crimx commented Jul 16, 2019

@crimx
Copy link

crimx commented Jul 16, 2019

Oh I see. It is reversed in EventCallback.

https://github.com/LeetCode-OpenSource/rxjs-hooks/blame/master/README.md#L203-L207

@crimx
Copy link

crimx commented Jul 16, 2019

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]
)

@OBe95
Copy link
Contributor

OBe95 commented Dec 10, 2019

@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

@zry656565
Copy link
Contributor

Fixed in #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants