Skip to content
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

Use reactive var hook #9906

Merged
merged 8 commits into from
Jul 19, 2022
Merged

Use reactive var hook #9906

merged 8 commits into from
Jul 19, 2022

Conversation

jpvajda
Copy link
Contributor

@jpvajda jpvajda commented Jul 15, 2022

This PR attempts to better document the useReactivevVar hook introduced in #6867

@jpvajda
Copy link
Contributor Author

jpvajda commented Jul 15, 2022

👋 @alessbell @MrDoomBringer @hwillson @benjamn

Here's an attempt to document this feature! Could someone provide a quick review?

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jpvajda! See my comments inline, but a few additional things:

  1. I think we should move this new content down further on the page. The useReactiveVar hook is a nice feature, but it is additive to the reactive variable functionality of the Apollo Client core. For this reason, I think we should introduce people to reactive variables as a core library concept first, then introduce them to the hook. I think your content would fit well merged into the Reacting part of this page, replacing the With the useReactiveVar hook ... paragraph.

  2. I think we should also document useReactiveVar alongside our other hooks, in the API section of the docs: https://www.apollographql.com/docs/react/api/react/hooks

Thanks again!

docs/source/local-state/reactive-variables.mdx Outdated Show resolved Hide resolved
docs/source/local-state/reactive-variables.mdx Outdated Show resolved Hide resolved
@jpvajda jpvajda requested a review from hwillson July 18, 2022 18:51
@jpvajda
Copy link
Contributor Author

jpvajda commented Jul 18, 2022

@hwillson I added to the API hooks docs, though you may want to review the function signature I pulled thatdefinition out of this change in the PR

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome @jpvajda - just one more small thing then I think we're 👍. Thanks!

Copy link
Member

@alessbell alessbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of stylistic nits that I'll let Stephen confirm/reject when he's back online, but overall found this very clear and easy to follow 😄

docs/source/api/react/hooks.mdx Show resolved Hide resolved
docs/source/api/react/hooks.mdx Outdated Show resolved Hide resolved
docs/source/api/react/hooks.mdx Outdated Show resolved Hide resolved
docs/source/local-state/reactive-variables.mdx Outdated Show resolved Hide resolved
docs/source/local-state/reactive-variables.mdx Outdated Show resolved Hide resolved
@jpvajda
Copy link
Contributor Author

jpvajda commented Jul 19, 2022

This is failing a single test in CI, but passes on my local branch.

Summary of all failing tests
 FAIL  link/batch/__tests__/batchLink.ts
  ● BatchLink › correctly follows batch interval

    expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      622 |       // The batch shouldn't be fired yet, so we can add one more request.
      623 |       const sub3 = batcher.enqueueRequest({operation: operation3}).subscribe(() => reject('next should never be called'));
    > 624 |       expect(batcher["batchesByKey"].get('')!.size).toBe(2);
          |                                                     ^
      625 |
      626 |       sub3.unsubscribe();
      627 |       expect(batcher["batchesByKey"].get('')!.size).toBe(1);

      at link/batch/__tests__/batchLink.ts:624:53
      at Timeout.task [as _onTimeout] (../node_modules/jsdom/lib/jsdom/browser/Window.js:514:19)


Test Suites: 1 failed, 115 passed, 116 total
Tests:       1 failed, 15 skipped, 1769 passed, 1785 total
Snapshots:   135 passed, 135 total
Time:        83.38 s
Ran all test suites.

Screen Shot 2022-07-19 at 4 23 06 PM

@jpvajda
Copy link
Contributor Author

jpvajda commented Jul 19, 2022

re running the test in Circle CI got it to pass. 🤷

@jpvajda jpvajda merged commit cc3ab27 into main Jul 19, 2022
@jpvajda jpvajda deleted the useReactiveVar-hook branch July 19, 2022 22:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants