Skip to content

Commit

Permalink
Linting 🙈
Browse files Browse the repository at this point in the history
  • Loading branch information
oldtinroof committed Jan 30, 2021
1 parent b09af9c commit 21d42dd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_
_
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ React-esque hooks.
[repl-custom-hash-history]:
https://svelte.dev/repl/195011a49a714e22b1a335037e124458
[repl-private-routes]: https://svelte.dev/repl/c81d8f3dff584065a82b2d3ea7cd4aee
[repl-private-routes-async]: https://svelte.dev/repl/97dc69c41e484b18971decfc46bcef4f
[repl-private-routes-async]:
https://svelte.dev/repl/97dc69c41e484b18971decfc46bcef4f
[repl-lazy-loading]: https://svelte.dev/repl/09abb8c287f745169f66f62d51f766d5
[repl-url-bar]: https://svelte.dev/repl/dc82bb89447647edb0d7ed8cbe7999ae
[repl-transitions]: https://svelte.dev/repl/c81d8f3dff584065a82b2d3ea7cd4aee
Expand All @@ -99,7 +100,8 @@ setups, or checkout the examples in the Svelte REPL:
- Simple basic usage in a client side rendered app
([examples][example-basic-client-side], [REPL][repl-basic-client-side])
- Private Routes for authenticated users only
([examples][example-private-routes], [REPL][repl-private-routes], [async example][example-private-routes-async])
([examples][example-private-routes], [REPL][repl-private-routes], [async
example][example-private-routes-async])
- Private Routes for authenticated users only (async auth check)
([examples][example-private-routes-async], [REPL][repl-private-routes-async])
- Using Routes to lazy load views ([examples][example-lazy-loading],
Expand Down
15 changes: 10 additions & 5 deletions example/private-routes-async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ logged in user.
In a `PrivateRoute` we use a `PrivateRouteGuard` component that redirects to a
login page if no user is set.

The `PrivateRouteGuard` in this example runs an asynchronous method to check authentication status. This could be something like [AWS Amplify's currentauthenticateduser](https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser), or another required async call. For the purposes of demonstration, this example uses a simple dummy async call that takes 1 second to respond.
The `PrivateRouteGuard` in this example runs an asynchronous method to check
authentication status. This could be something like
[AWS Amplify's currentauthenticateduser](https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser),
or another required async call. For the purposes of demonstration, this example
uses a simple dummy async call that takes 1 second to respond.

The `PrivateRouteGuard` sets the current location pathname as a state in the redirect,
so that we know from which private page we came. The `Login` component can then,
upon successful login, redirect back to the private page.
The `PrivateRouteGuard` sets the current location pathname as a state in the
redirect, so that we know from which private page we came. The `Login` component
can then, upon successful login, redirect back to the private page.

### Try it out

Expand All @@ -24,4 +28,5 @@ npm start # 'yarn start'

### Background

This example was created from the result of the conversation in [issue 29 on github](https://github.com/mefechoel/svelte-navigator/issues/29)
This example was created from the result of the conversation in
[issue 29 on github](https://github.com/mefechoel/svelte-navigator/issues/29)
8 changes: 4 additions & 4 deletions example/private-routes-async/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { writable } from "svelte/store";
export const user = writable(null);

export const asyncCheckAuthStatus = async () => {
// this could be a call to Amplify currentUserInfo or another async auth library
// you could use the response to set user if success
// or throw an error if user not found
await new Promise(resolve => setTimeout(resolve, 1000));
// this could be a call to Amplify currentUserInfo or another async auth library
// you could use the response to set user if success
// or throw an error if user not found
await new Promise(resolve => setTimeout(resolve, 1000));
};
17 changes: 8 additions & 9 deletions test/testApp/src/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"data-has-attr": true,
"data-duplicate-attr": "getProps",
})}
to="about"
>GET PROPS</Link
to="about">GET PROPS</Link
>
<Link data-testid="link-about-rel" to="about">ABOUT REL</Link>
<Link data-testid="link-about-abs" to="/about">ABOUT ABS</Link>
Expand All @@ -46,8 +45,7 @@
<Link
data-testid="link-about-push-state"
to="about"
state={{ value: "test-push-state" }}
>ABOUT PUSH STATE</Link
state={{ value: "test-push-state" }}>ABOUT PUSH STATE</Link
>
<Link data-testid="link-about-replace" to="about" replace>
ABOUT REPLACE
Expand All @@ -56,8 +54,7 @@
data-testid="link-about-replace-state"
to="about"
state={{ value: "test-replace-state" }}
replace
>ABOUT REPLACE STATE</Link
replace>ABOUT REPLACE STATE</Link
>
<Link data-testid="link-blog" to="blog">BLOG</Link>
<Link data-testid="link-blog-match-empty" to="blog/match">MATCH EMPTY</Link>
Expand All @@ -66,8 +63,7 @@
</Link>
<Link
data-testid="link-blog-match-to-splat"
to="blog/match/some-path/some-splat"
>MATCH SOME PATH AND SPLAT</Link
to="blog/match/some-path/some-splat">MATCH SOME PATH AND SPLAT</Link
>

<div use:links>
Expand Down Expand Up @@ -100,7 +96,10 @@
<a
use:link={customNavigate}
data-testid="action-link-custom-navigate"
href="/about"> ACTION LINK ABOUT CUSTOM NAVIGATE </a>
href="/about"
>
ACTION LINK ABOUT CUSTOM NAVIGATE
</a>
</nav>
<br />
<main>
Expand Down

0 comments on commit 21d42dd

Please # to comment.