Skip to content

Commit 0acc863

Browse files
authored
Merge pull request #35 from invertase/next
feat: rework realtime subscription hooks
2 parents 4446a4c + b72191c commit 0acc863

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+19361
-4101
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
**/dist/**/*.*
2-
**/coverage/**/*.*
2+
**/coverage/**/*.*

.opensource/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"pages": [],
66
"related": ["firebase/firebase-js-sdk", "tannerlinsley/react-query"],
77
"tabs": []
8-
}
8+
}

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/lib/**
2+
node_modules
3+
*.js
4+
*.json
5+
*.md
6+
*.yaml
7+
coverage

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
<br />
1111

1212
React Query Firebase provides a set of easy to use hooks for handling asynchronous tasks with Firebase in your React application.
13+
1314
## Why should I use React Query Firebase?
1415

1516
- **Backed by React Query** - Unlike other solutions, hooks are built on top of [React Query](https://react-query.tanstack.com) which takes care of complex challenges
16-
such as caching, automatic refetching, realtime data subscriptions, pagination & infinite queries, mutations, SSR Support, data selectors, side effect handlers and more. You also get [DevTool](https://react-query.tanstack.com/devtools)
17-
support out of the box!
17+
such as caching, automatic refetching, realtime data subscriptions, pagination & infinite queries, mutations, SSR Support, data selectors, side effect handlers and more. You also get [DevTool](https://react-query.tanstack.com/devtools)
18+
support out of the box!
1819
- **Un-opinionated** - You provide the Query Keys, Configuration & Firebase instances, allowing for full control over how your data is integrated and cached. You can also roll it alongside any existing Firebase usage.
19-
- **Performant & Efficient** - Whether your queries are one-off or realtime, the library is designed to be performant and efficient. Data fetching is handled via [Queries](https://react-query.tanstack.com/guides/queries) and
20-
[Query Keys](https://react-query.tanstack.com/guides/query-keys), meaning components can share data throughout your application without needless database reads.
21-
- **Mutations** - Sign a user in, delete a document, run a transaction, log an event... React Query Firebase takes care of that for you via [Mutations](https://react-query.tanstack.com/guides/mutations), allowing you to focus
22-
on your application and not managing complex local loading & error states.
20+
- **Performant & Efficient** - Whether your queries are one-off or realtime, the library is designed to be performant and efficient. Data fetching is handled via [Queries](https://react-query.tanstack.com/guides/queries) and
21+
[Query Keys](https://react-query.tanstack.com/guides/query-keys), meaning components can share data throughout your application without needless database reads.
22+
- **Mutations** - Sign a user in, delete a document, run a transaction, log an event... React Query Firebase takes care of that for you via [Mutations](https://react-query.tanstack.com/guides/mutations), allowing you to focus
23+
on your application and not managing complex local loading & error states.
2324
- **Fully Typed** - The library is built with and has full compatibility with TypeScript.
2425

2526
> **Note**: The library supports the Firebase JS SDK v9 - [learn more about it here](https://firebase.googleblog.com/2021/08/the-new-firebase-js-sdk-now-ga.html)!

docs/analytics/typescript.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Hooks for integrating with Firebase Analytics.
55

66
# TypeScript
77

8-
The library exposes the various type interfaces for logging events to Analytics.
8+
The library exposes the various type interfaces for logging events to Analytics.
99
The interface map below outlines the various event names and their interfaces:
1010

1111
```ts
@@ -41,6 +41,6 @@ mutation.mutate({
4141
params: {
4242
firebase_screen: "Search",
4343
firebase_screen_class: "SearchPage",
44-
}
45-
})
46-
```
44+
},
45+
});
46+
```

docs/auth/actions.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ const mutation = useAuthUnlink();
487487

488488
mutation.mutate({
489489
user: auth.currentUser,
490-
providerId: 'google.com',
490+
providerId: "google.com",
491491
});
492492
```
493493

@@ -515,7 +515,7 @@ const mutation = useAuthUpdateEmail();
515515

516516
mutation.mutate({
517517
user: auth.currentUser,
518-
newEmail: '[email protected]',
518+
newEmail: "[email protected]",
519519
});
520520
```
521521

@@ -530,7 +530,7 @@ const mutation = useAuthUpdatePassword();
530530

531531
mutation.mutate({
532532
user: auth.currentUser,
533-
newPassword: '...',
533+
newPassword: "...",
534534
});
535535
```
536536

@@ -561,8 +561,8 @@ const mutation = useAuthUpdateProfile();
561561

562562
mutation.mutate({
563563
user: auth.currentUser,
564-
displayName: '...', // optional
565-
photoURL: 'https://...', // optional
564+
displayName: "...", // optional
565+
photoURL: "https://...", // optional
566566
});
567567
```
568568

@@ -577,7 +577,7 @@ const mutation = useAuthVerifyBeforeUpdateEmail();
577577

578578
mutation.mutate({
579579
user: auth.currentUser,
580-
newEmail: '[email protected]',
580+
newEmail: "[email protected]",
581581
actionCodeSettings: {}, // optional
582582
});
583583
```
@@ -591,6 +591,5 @@ Checks a password reset code sent to the user by email or other out-of-band mech
591591
```js
592592
const mutation = useAuthVerifyPasswordResetCode(auth);
593593

594-
mutation.mutate('oobCode');
594+
mutation.mutate("oobCode");
595595
```
596-

docs/auth/auth-state.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function App() {
3535
```
3636

3737
Anytime your users state changes, the hooks data will be updated allowing you to reactively handle updates
38-
within your application. If the user is authenticated, the hook returns the
38+
within your application. If the user is authenticated, the hook returns the
3939
[`User`](https://firebase.google.com/docs/reference/js/auth.user) interface, otherwise it's `null`.
4040

4141
## Sharing a Query Key
@@ -86,13 +86,11 @@ side effects with ease:
8686
const user = useAuthUser(["user"], auth, {
8787
onSuccess(user) {
8888
if (user) {
89-
console.log('User is authenticated!', user);
89+
console.log("User is authenticated!", user);
9090
}
9191
},
9292
onError(error) {
93-
console.error('Failed to subscribe to users authentication state!');
94-
}
93+
console.error("Failed to subscribe to users authentication state!");
94+
},
9595
});
9696
```
97-
98-

docs/auth/id-token.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ useAuthIdToken(["token"], auth, {
8686
if (result) {
8787
return result.token;
8888
} else {
89-
return '';
89+
return "";
9090
}
9191
},
9292
});

docs/auth/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Hooks for integrating with Authentication.
55

66
# Authentication
77

8-
The `@react-query-firebase/auth` package provides hooks subscribing to a authentication state and triggering
8+
The `@react-query-firebase/auth` package provides hooks subscribing to a authentication state and triggering
99
authentication requests.
1010

1111
## Installation

docs/comparison.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and stale data with zero configuration. It also provides tools such as DevTools,
1212

1313
Alongside this, React Query Firebase is unopinionated when it comes to integrating with both Firebase and React Query. You can use the library alongside
1414
your existing Firebase or React Query code with zero conflict. You provide the [Query Keys](https://react-query.tanstack.com/guides/query-keys) and a
15-
Firebase instance and the library does the rest. Each hook allows you to also provide React Query hook options, which opens the door to making integration
15+
Firebase instance and the library does the rest. Each hook allows you to also provide React Query hook options, which opens the door to making integration
1616
with the rest of your application super powerful.
1717

1818
Since we've also got access to the awesome [`useMutation`](https://react-query.tanstack.com/reference/useMutation) hook, it means the library provides super useful
@@ -44,5 +44,5 @@ return (
4444
);
4545
```
4646

47-
In this simple example, we've got success and error callback handlers alongside reactive updates within our application, with zero custom local
47+
In this simple example, we've got success and error callback handlers alongside reactive updates within our application, with zero custom local
4848
state management. By integrating with React Query, it allows us to build complex logic flows with minimal effort.

0 commit comments

Comments
 (0)