File tree 1 file changed +20
-1
lines changed
apps/browser-example/src/components
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,21 @@ export function EventList({ events }: { events: any[] }) {
36
36
}
37
37
} , [ events ] )
38
38
39
+ function saveEvents ( ) {
40
+ const blob = new Blob ( [ JSON . stringify ( events , null , 2 ) ] , {
41
+ type : "application/json" ,
42
+ } )
43
+ const url = URL . createObjectURL ( blob )
44
+ const a = document . createElement ( "a" )
45
+ a . href = url
46
+ const timestamp = new Date ( ) . toISOString ( ) . replace ( / [: .] / g, "-" )
47
+ a . download = `events-${ timestamp } .json`
48
+ a . click ( )
49
+ }
50
+
39
51
return (
40
52
< div className = "card my-2" >
41
- < div className = "card-header" >
53
+ < div className = "card-header d-flex gap-2 " >
42
54
< div className = "dropdown" >
43
55
< button
44
56
type = "button"
@@ -49,6 +61,13 @@ export function EventList({ events }: { events: any[] }) {
49
61
>
50
62
Filter
51
63
</ button >
64
+ < button
65
+ type = "button"
66
+ className = "btn btn-secondary"
67
+ onClick = { ( ) => saveEvents ( ) }
68
+ >
69
+ Save Events to File
70
+ </ button >
52
71
< span className = "mx-2" > Event Count: { events . length } </ span >
53
72
54
73
< form
You can’t perform that action at this time.
0 commit comments