1
+ < html >
2
+
3
+ </ html >
4
+
5
+ < head >
6
+ < meta content ="text/html;charset=utf-8 " http-equiv ="Content-Type " />
7
+ < link rel ="stylesheet "
8
+ href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css ">
9
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js "> </ script >
10
+ </ head >
11
+
12
+ < body >
13
+ < script type ="module ">
14
+ import init , { createClient , ClientConfig } from '../pkg/dojo_c.js' ;
15
+ import { ThemeManager , UpdateManager } from './setup.js' ;
16
+
17
+ const themeManager = new ThemeManager ( ) ;
18
+ const updateManager = new UpdateManager ( ) ;
19
+
20
+ async function run ( ) {
21
+ await init ( ) ;
22
+
23
+ let config = {
24
+ rpcUrl : 'http://localhost:5050' ,
25
+ toriiUrl : 'http://localhost:8080' ,
26
+ relayUrl : '' ,
27
+ worldAddress : '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
28
+ }
29
+
30
+ let cconfig = new ClientConfig ( config . rpcUrl , config . toriiUrl , config . relayUrl , config . worldAddress ) ;
31
+ const client = await createClient ( cconfig ) ;
32
+
33
+ let events = await client . getEventMessages ( {
34
+ limit : 10 ,
35
+ offset : 0 ,
36
+ dont_include_hashed_keys : true ,
37
+ order_by : [ ] ,
38
+ entity_models : [ ] ,
39
+ clause : {
40
+ Keys : {
41
+ keys : [ undefined ] ,
42
+ pattern_matching : "VariableLen" ,
43
+ models : [ ]
44
+ }
45
+ }
46
+ } ) ;
47
+
48
+ updateManager . displayUpdate ( 'fetch' , events ) ;
49
+
50
+ const is_historical = false ;
51
+
52
+ const subscription = await client . onEventMessageUpdated (
53
+ [
54
+ {
55
+ Keys : {
56
+ keys : [ undefined ] ,
57
+ pattern_matching : "VariableLen" ,
58
+ models : [ ]
59
+ }
60
+ }
61
+ ] ,
62
+ is_historical ,
63
+ ( updatedEvents ) => {
64
+ updateManager . displayUpdate ( 'update' , updatedEvents ) ;
65
+ } ) ;
66
+
67
+ // Keeps the subscription alive.
68
+ window . addEventListener ( 'beforeunload' , ( ) => {
69
+ if ( subscription ) {
70
+ subscription . cancel ( ) ;
71
+ }
72
+ } ) ;
73
+ }
74
+
75
+ run ( ) . catch ( error => {
76
+ console . error ( error ) ;
77
+ updateManager . displayUpdate ( 'error' , error . toString ( ) ) ;
78
+ } ) ;
79
+
80
+ console . log ( "a" ) ;
81
+ </ script >
82
+ </ body >
83
+
84
+ </ html>
0 commit comments