@@ -17,74 +17,4 @@ An IPC[^1] system for MCBE Script API projects
17
17
18
18
** TypeScript**
19
19
1 . Download ` ipc.ts ` from the latest [ release] ( https://github.com/OmniacDev/MCBE-IPC/releases/latest )
20
- 2 . Copy file into your project
21
-
22
- ## Usage
23
-
24
- ### Sending & Receiving
25
-
26
- ` IPC.send() ` and ` IPC.on() ` can be used to send messages or data between packs.
27
-
28
- _ Pack 1_
29
- ``` js
30
- import IPC from ' ipc.js'
31
-
32
- IPC .on (' message_channel' , (args ) => {
33
- console .log (` Message: ${ args} ` )
34
- })
35
-
36
- IPC .on (' data_channel' , (args ) => {
37
- console .log (` Data: ${ args .example_bool } , ${ args .example_number } ` )
38
- })
39
- ```
40
- _ Pack 2_
41
- ``` js
42
- import IPC from ' ipc.js'
43
-
44
- IPC .send (' message_channel' , ' Example Message' )
45
-
46
- IPC .send (' data_channel' , { example_number: 100 , example_bool: true })
47
- ```
48
- _ Console Output_
49
- ```
50
- Message: Example Message
51
- Data: true, 100
52
- ```
53
-
54
- ### Requesting & Serving
55
-
56
- ` IPC.invoke() ` and ` IPC.handle() ` can be used to request and serve data between packs.
57
-
58
- _ Pack 1_
59
- ``` js
60
- import IPC from ' ipc.js'
61
-
62
- IPC .handle (' request_channel' , (args ) => {
63
- switch (args) {
64
- case ' status' :
65
- return ' inactive'
66
- case ' size' :
67
- return 100
68
- }
69
- })
70
- ```
71
- _ Pack 2_
72
- ``` js
73
- import IPC from ' ipc.js'
74
-
75
- IPC .invoke (' request_channel' , ' status' ).then (result => {
76
- console .log (` Status: ${ result} ` )
77
- })
78
-
79
- IPC .invoke (' request_channel' , ' size' ).then (result => {
80
- console .log (` Size: ${ result} ` )
81
- })
82
- ```
83
- _ Console Output_
84
- ```
85
- Status: inactive
86
- Size: 100
87
- ```
88
-
89
-
90
-
20
+ 2 . Copy file into your project
0 commit comments