File tree Expand file tree Collapse file tree 5 files changed +24
-27
lines changed
_official-realtime-app/app Expand file tree Collapse file tree 5 files changed +24
-27
lines changed Original file line number Diff line number Diff line change 1
1
import type { LinksFunction , MetaFunction } from "@remix-run/node" ;
2
+ import { json } from "@remix-run/node" ;
2
3
import {
3
4
Links ,
4
5
Meta ,
@@ -52,6 +53,6 @@ function useRealtimeIssuesRevalidation() {
52
53
53
54
// FIXME: Pointless action for revalidation until:
54
55
// https://github.com/remix-run/remix/issues/4485
55
- export function action ( ) {
56
- return { ok : true } ;
56
+ export async function action ( ) {
57
+ return json ( { ok : true } ) ;
57
58
}
Original file line number Diff line number Diff line change
1
+ import { json } from "@remix-run/node" ;
1
2
import { Link , useFetcher , useNavigate } from "@remix-run/react" ;
2
3
import { useLoaderData } from "@remix-run/react" ;
3
4
import classNames from "classnames" ;
4
5
import { useEffect , useRef } from "react" ;
5
6
6
- import { getIssues } from "../data " ;
7
- import type { Issue } from ".. /data" ;
8
- import * as AmalgoBox from "../amalgo-box.client " ;
9
- import icons from ".. /icons.svg" ;
7
+ import * as AmalgoBox from "~/amalgo-box.client " ;
8
+ import type { Issue } from "~ /data" ;
9
+ import { getIssues } from "~/data " ;
10
+ import icons from "~ /icons.svg" ;
10
11
11
- export function loader ( ) {
12
- return getIssues ( ) ;
12
+ export async function loader ( ) {
13
+ return json ( await getIssues ( ) ) ;
13
14
}
14
15
15
16
export default function Index ( ) {
16
- const issues = useLoaderData ( ) as Issue [ ] ;
17
+ const issues = useLoaderData < typeof loader > ( ) ;
17
18
18
19
useEffect ( ( ) => AmalgoBox . registerCustomElements ( ) , [ ] ) ;
19
20
return (
Original file line number Diff line number Diff line change 1
- import { type DataFunctionArgs } from "@remix-run/node" ;
1
+ import type { LoaderArgs } from "@remix-run/node" ;
2
2
import { eventStream } from "remix-utils" ;
3
3
4
- import { emitter , EVENTS } from ".. /events" ;
4
+ import { emitter , EVENTS } from "~ /events" ;
5
5
6
- export const loader = ( { request } : DataFunctionArgs ) => {
6
+ export const loader = async ( { request } : LoaderArgs ) => {
7
7
return eventStream ( request . signal , ( send ) => {
8
8
const handler = ( message : string ) => {
9
9
send ( { data : message } ) ;
Original file line number Diff line number Diff line change
1
+ import type { LoaderArgs , MetaFunction } from "@remix-run/node" ;
1
2
import { json } from "@remix-run/node" ;
2
- import type { DataFunctionArgs , SerializeFrom } from "@remix-run/node" ;
3
3
import { useFetcher , useLoaderData } from "@remix-run/react" ;
4
4
import invariant from "tiny-invariant" ;
5
5
6
6
import { getIssue } from "~/data" ;
7
7
8
- export const loader = async ( { params } : DataFunctionArgs ) => {
8
+ export const loader = async ( { params } : LoaderArgs ) => {
9
9
invariant ( params . id , "Missing issue id" ) ;
10
10
const issue = await getIssue ( params . id ) ;
11
11
if ( ! issue ) {
12
12
throw json ( "Issue not found" , { status : 404 } ) ;
13
13
}
14
- return issue ;
14
+ return json ( issue ) ;
15
15
} ;
16
16
17
- export const meta = ( {
18
- data : issue ,
19
- } : {
20
- data : SerializeFrom < typeof loader > ;
21
- } ) => {
22
- return {
23
- title : issue ?. title || "Not Found" ,
24
- } ;
25
- } ;
17
+ export const meta : MetaFunction < typeof loader > = ( { data : issue } ) => ( {
18
+ title : issue ?. title || "Not Found" ,
19
+ } ) ;
26
20
27
21
export default function Issue ( ) {
28
22
const issue = useLoaderData < typeof loader > ( ) ;
Original file line number Diff line number Diff line change 1
- import { type DataFunctionArgs } from "@remix-run/node" ;
1
+ import type { ActionArgs } from "@remix-run/node" ;
2
+ import { json } from "@remix-run/node" ;
2
3
import invariant from "tiny-invariant" ;
3
4
4
5
import { updateIssue } from "~/data" ;
5
6
import { emitter , EVENTS } from "~/events" ;
6
7
7
- export const action = async ( { params, request } : DataFunctionArgs ) => {
8
+ export const action = async ( { params, request } : ActionArgs ) => {
8
9
const updates = Object . fromEntries ( await request . formData ( ) ) ;
9
10
invariant ( params . id , "Missing issue id" ) ;
10
11
const result = await updateIssue ( params . id , updates ) ;
11
12
emitter . emit ( EVENTS . ISSUE_CHANGED , Date . now ( ) ) ;
12
- return result ;
13
+ return json ( result ) ;
13
14
} ;
You can’t perform that action at this time.
0 commit comments