Review of Angular 2, RxJS, and Reducers from ngrx/store
lessonDuration 3m 38s
This lesson summarizes everything the course has covered and how Angular 2, RxJS, and ngrx/store work together to achive a reactive application.
Browse
Find courses, lessons, articles, talks, and podcasts.
7,176 resources
Showing 841–864 · Page 36 of 299
lessonDuration 3m 38s
This lesson summarizes everything the course has covered and how Angular 2, RxJS, and ngrx/store work together to achive a reactive application.
lessonDuration 39s
In this lesson, we use the element inspector in Chrome to test and improve our contrast to meet WCAG AA Contrast Ratio Standards. Resources: - [WebAIM - Contrast and Color Accessibility](https://webaim.org/articles/contrast/)
lessonDuration 1m 12sFree
course
[Supabase](http://supabase.com?utm_source=egghead&utm_campaign=remix) is a collection of open-source tools that wrap around a PostgreSQL database. In this course, we look at building a realtime chat application with Remix, using Supabase for db hosting, authentication, authorization and subscribe to realtime db events - updating the UI as the database changes. We will learn about: - loaders and actions in Remix - querying and mutating data with Supabase - authentication with GitHub - authorization with RLS - merging client and server state with realtime events - deploying a Remix app to Vercel This course is 100% TypeScript, however, don't stress if you don't have any experience with TS, as Supabase does most of the heavy lifting here! 🎉
lessonDuration 2m 29s
It's a waste of computation resources to run your build scripts if there haven't been any changes. Nx's caching features save you time and resources. Get started by just running the `nx init` command and then setting the scripts you want to cache in the generated `nx.json`
lessonDuration 2m 16s
I suggest using the previously learned approach but keep in mind that it may lead to an overly complex markup. We also use the `aria-label` attribute, which can be used to override the text within a label element. **Think about:** Why would you use an `aria-label` instead of creating a visually hidden span?
lessonDuration 4m 19sFree
The Redux devtools allow you to see what happens internally when you use RTK Query in an application. We'll explore the actions that are dispatched when API endpoints are hit and the data associated with them as well as the RTK Query cache that is being maintained in the background. We'll also see how RTK Query manages the cache by default.
lessonDuration 4m 34sFree
TypeScript is increasingly being used instead of JavaScript in many projects. We'll look at converting our application to TypeScript and see what benefits that brings. TypeScript will show us all the methods that we have available on our API along with our hooks we use to consume our API. In addition to this, we'll get situational typing that will tell us what data is available to us given a loading state. This will catch a lot of bugs in our code.
lessonDuration 1m 57s
You can use pnpm's --filter flag to run scripts in any app in your monorepo from the root of the project. All you have to do is ensure that each of your app's have `name` set in their `package.json` file. Then you can run, for example, `pnpm --filter my-remix-app dev`.
lessonDuration 4m 13sFree
The first thing we need to do to set up Redux Toolkit Query is to create API end points and wrap our application in an `ApiProvider` that RTK Query gives us. For this application, we will expose two endpoints. One endpoint will be the list of all pokemon and the other will be the pokemon detail page. Then we'll use the endpoints we built and load the data from RTK Query hooks along with loading and error states.
lessonDuration 1m 25sFree
In many applications that you'll use RTK Query in you will have a Redux store. This lesson shows you the basic steps it takes to convert from using `ApiProvider` by configuring your Redux store with an API slice.
lessonDuration 1m 50sFree
There are a lot of edge cases that our simple fetch code is not handling. RTK Query has a great utility function called `fetchBaseQuery` that will execute a fetch and handle those annoying edge cases that you don't need to think through. We will refactor to use `fetchBaseQuery` with a "base url" and explore some new options like `params` and `method` we get as a result.
lessonDuration 1m 1sFree
We can reduce code duplication using a `baseQuery` from RTK Query. We do this by moving duplicate code into a `baseQuery` function and writing `query` functions instead of `queryFn`. The return value of those `query` functions will be passed on as first argument into the `baseQuery`.
lessonDuration 48sFree
Our pokemon detail query is hard coded to a single pokemon. We want to be able to click on any pokemon to navigate to that pokemons detail page. Making queries dynamic in RTK Query is as easy as passing the data into the hook destructuring that data in the query function.
lessonDuration 1m 13sFree
Currently our implementation just returns hardcoded data that we have in JSON. We want real data! This lesson swaps out our hardcoded data for real endpoints.
lessonDuration 1m 32sFree
The application that we will be working on displays a list of Pokemon and their details. Currently, the data is hard coded and all pokemon show bulbasaur on the details page. In this lesson, I give you a basic walk through of how our app is set up so you can get started migrating to RTK Query.
lessonDuration 1m 52s
In this course, we'll be focusing on building an accessible component by using a built-in browser API with React to implement best practices in accessibility custom features. Everyone is responsible for accessibility, and we need to start creating features and websites with that in mind. The goal of this course is for you to exploit your understanding of HTML and aria, and be able to look at any common features and identify the different accessibility patterns. With this course you won't only learn about accessibility, but also will learn about `HTMLMediaElement` API, and state management in React.
lessonDuration 2m 51s
We will create two buttons labeled "rewind 15 seconds" and "fast forward 15 seconds." Then, we created two functions, `onRewind` and `onFastForward`, to adjust the current time of a media by 15 seconds. The `onRewind` function will use `Math.max` to ensure that the time does not go into negative, and the `onFastForward` function will use `Math.min` to set a max limit. These functions will be added to the click events of the corresponding buttons. Finally, it sets the new time for the media state and the audio reference. **Think about:** Why do you need the second parameter for `math.max` and `math.min`?
lessonDuration 2m 56sFree
The OAuth flow is asynchronous. This means we get redirected to the landing page before GitHub and Supabase have decided that you can be trusted! 👍 Since our Loader functions get called when we first load the page they make a request to Supabase before receiving a valid access token. This causes RLS to deny the request to select data. Once our session has been correctly set, Supabase is happy but we aren't telling Remix to fetch this data again. In this lesson, we look at combining the `onAuthStateChange` hook from Supabase with the `useRevalidator` hook in Remix to recall any active `loaders` when the state of our user changes, keeping data in sync with mutations. Therefore, any time the user's session is updated - the auth flow has completed for either signing in or out - Remix will automatically call all loader functions that are active on the current route (this could be many with nested routing), fetching fresh data from Supabase with a valid access token. ## Code Snippets **onAuthStateChange listener** ```tsx useEffect(() => { const { data: { subscription }, } = supabase.auth.onAuthStateChange((event, session) => { if (session?.access_token !== serverAccessToken) { revalidator.revalidate() } }); return () => { subscription.unsubscribe(); }; }, [supabase, serverAccessToken, revalidator]); ``` ## Resources - [Supabase docs - onAuthStateChange](https://supabase.com/docs/reference/javascript/auth-onauthstatechange) - [Reactor Router docs - useRevalidator](https://reactrouter.com/en/main/hooks/use-revalidator)
lessonDuration 3m 5s
React's `forwardRef` function allows a component to receive a ref that has been created outside of it. This can be useful in cases where you want to have a specific part of your component, such as a section of a long transcript or a specific part of an audio recording, referenced from outside the component. One example of when this might be useful is if you have a "listicle" type of audio, such as "5 things your tech resume needs", and you want to allow users to jump to specific parts of the audio. By converting the component to a forwarded ref component, you can create a ref in the parent component (in this case, the "App" component) and pass it into the audio component. This allows you to create a few buttons in the parent component that can control the audio ref and jump to specific audio sections. To convert a component to a forwarded ref component, you can use React's `forwardRef` function to wrap the component, and then remove the audio ref and replace all instances with the new ref. By doing this, you can now control the audio component, like play, pause and jump to a specific time, by interacting with the `audioRef` ref object created in the parent component and passed into the audio component. **Think about:** What ways to control the audio outside the component could help with accessibility?
lessonDuration 3m 50sFree
With Actions you have the option to use pre-configured Actions from the [Auth0 Marketplace](https://marketplace.auth0.com/features/actions). Add the [Country-based Access](https://marketplace.auth0.com/integrations/country-based-access) Action to your Action library to restrict users access based on their country. Once the Action is added to your library, choose the Login flow trigger. Use the drag and drop flow editor to add the Country-based Access Action to the Auth0 login flow.
lessonDuration 4m 11sFree
TypeScript helps us build more robust, maintainable and safe applications. In this lesson, we look at installing the [Supabase CLI](https://supabase.com/docs/reference/cli), and using it to generate type definitions for Supabase. We can use this to add TypeScript support to our Supabase client, which flows through our entire application - server and client. This means we get in-editor feedback about what we can and can't do with Supabase, helping to discover cool new things, while reducing bugs. Additionally, we use the `LoaderArgs` type signature for our Loader function, which allows us to infer the return type in our component. > Note: this does not automatically update with changes to Supabase. You need to manually run this command whenever you change the structure of the database. ## Code Snippets **Generate TypeScript definitions from Supabase** ```bash supabase gen types typescript --project-id your-project-id > db_types.ts ``` **Create typesafe Supabase client** ```tsx import { createClient } from "@supabase/supabase-js"; import type { Database } from "db_types"; export default createClient<Database>( process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY! ); ``` **Fetch data with end-to-end type defs** ```tsx import { useLoaderData } from "@remix-run/react"; import supabase from "utils/supabase"; import type { LoaderArgs } from "@remix-run/node"; export const loader = async ({}: LoaderArgs) => { const { data } = await supabase.from("messages").select(); return { messages: data ?? [] }; }; export default function Index() { const { messages } = useLoaderData<typeof loader>(); return <pre>{JSON.stringify(messages, null, 2)}</pre>; } ``` ## Resources - [Supabase CLI](https://supabase.com/docs/reference/cli) - [Supabase TypeScript Support](https://supabase.com/docs/reference/javascript/typescript-support) - [Remix decision to infer types](https://github.com/remix-run/remix/blob/main/decisions/0003-infer-types-for-useloaderdata-and-useactiondata-from-loader-and-action-via-generics.md)
lessonDuration 1m 27s
Even running all your scripts at once will get slow and tedious as your project grows. That's where Nx come in. [Nx will generally optimize the experience with caching and selectively running commands.](https://nx.dev/)
lessonDuration 2m 58sFree
Row Level Security denies all access to the database. Select, insert, update and delete queries will be blocked by default. This allows us to write access policies in the database itself, to allow only what our application needs to function. In this lesson, we look at adding a `user_id` column to the `messages` table, which has a foreign key relationship to the `auth.users` table - what Supabase uses to manage authentication and sessions. Additionally, we step through a common migration pattern to use when existing data conflicts with the constraints of a new change in structure - we want each message to belong to a user, but the existing data had no column for `user_id`. This requires a three-step process where we add the column without the `not null` constraint, update the existing data to belong to a user, and then add the `not null` constraint to the `user_id` column. Lastly, we update our RLS policy to only allow read access to signed in users. ## Code Snippets > SQL code snippets can be run against your Supabase database by heading over to your project's [SQL Editor](https://app.supabase.com/project/_/sql), pasting them into a new query, and clicking `RUN`. **Add column with not null constraint** ```sql alter table public.messages add user_id uuid references auth.users not null; ``` **Add column without not null constraint** ```sql alter table public.messages add user_id uuid references auth.users; ``` **Add not null constraint to column** ```sql alter table public.messages alter column user_id set not null; ``` **Alter RLS policy to require authenticated user** ```sql begin; alter policy "users can read messages" on "public"."messages" rename to "authenticated users can read messages"; alter policy "authenticated users can read messages" on "public"."messages" to authenticated; commit; ``` ## Resources - [Implement Row Level Security in Supabase (video)](https://www.youtube.com/watch?v=Ow_Uzedfohk)