0.2.0 • Published 12 months ago

@data-client/hooks v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 months ago

Networking Hooks

CircleCI Coverage Status npm downloads bundle size npm version PRs Welcome

Composable hooks for networking data

📖Read The Docs

🚨 Repository Deprecated and Moved! 🚨

This repository has been deprecated and is no longer actively maintained. All hooks moved to @data-client/react

useCancelling()

Aborts inflight request if the parameters change.

const data = useSuspense(useCancelling(MyEndpoint, { filter }), { filter });

useDebounce()

Delays updating the parameters by debouncing. Useful to avoid spamming network requests when parameters might change quickly (like a typeahead field).

const debouncedFilter = useDebounce(filter, 200);
const data = useSuspense(SearchList, { filter: debouncedFilter });

useLoading()

Helps track loading state of imperative async functions.

function Button({ onClick, children, ...props }) {
  const [clickHandler, loading, error] = useLoading(onClick);
  return (
    <button onClick={clickHandler} {...props}>
      {loading ? 'Loading...' : children}
    </button>
  );
}
0.1.11

1 year ago

0.2.0

12 months ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago