How to use the rxjs-hooks.useEventCallback function in rxjs-hooks

To help you get started, we’ve selected a few rxjs-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firekylin / firekylin / www / static / src / routes / tag / list / list.tsx View on Github external
export function TagList(props: TagProps) {
    const [loading, setLoading] = useState(false);

    const [eventCallback, tagList] = useEventCallback((event$: Observable>) => {
        return event$.pipe(
            startWith([]),
            switchMap(() => TagAPI.queryTagList()),
            tap(() => {
                setLoading(false);
            }),
            catchError(err => {
                console.error(err);
                return of([]);
            })
        );
    }, []);

    function tagDelete(e: React.MouseEvent, id: number) {
        confirm({
            title: '提示',
github bnankiewicz / organic / src / experiments / gestures.tsx View on Github external
)

  const data = refs.current
  const getTargetRowIdx = (event: PanGestureHandlerGestureEvent['nativeEvent']) => {
    const currentPosition = event.absoluteY
    let targetIdx = 0
    const res = reduceWhile((acc) => acc {
      targetIdx += 1
      acc += data.rowHeights[val]
      return acc
    },0)(ordering)
    setMarkerPosition(res)
    data.targetItemIndex = targetIdx
  }

  const [itemLayoutCallback, [itemLayout]] = useEventCallback(
    event$ =>
      event$.pipe(
        map(([event, itemIndex]: [LayoutChangeEvent, OrgEntry]) => [
          event.nativeEvent.layout.height,
          itemIndex,
        ]),
        tap(([height, itemId]) => (refs.current.rowHeights[itemId] = height))
      ),
    []
  )

  const [panGestureListenerCallback, [event]] = useEventCallback(
    event$ =>
      event$.pipe(
        map((event: PanGestureHandlerGestureEvent) => [event.nativeEvent]),
        auditTime(100),

rxjs-hooks

React hooks for RxJS

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis