@@ -21,17 +21,31 @@ A react component to render a code cell in your app.
21
21
22
22
#### Props
23
23
24
- | Prop | Type | Description |
25
- | ------------- | ---------------------- | ------------------------------------------------------------------ |
26
- | ` cellId ` | ` string ` | Unique id for the cell |
27
- | ` appName ` | ` string ` | Unique app name |
28
- | ` code ` | ` string ` | Initial code for the cell |
29
- | ` onAOProcess ` | ` (pid:string) => void ` | Callback function that gets called whenever a process is is loaded |
30
- | ` width ` | ` string ` | Width of the cell |
31
- | ` height ` | ` string ` | Height of the cell |
32
- | ` className ` | ` string ` | Class names for styling |
33
- | ` style ` | ` React.CSSProperties ` | Inline styles |
34
- | ` devMode ` | ` boolean ` | Boolean to enable dev mode |
24
+ | Prop | Type | Description |
25
+ | -------------- | ------------------------ | ----------------------------------------------------------------------------- |
26
+ | ` cellId ` | ` string ` | Unique id for the cell |
27
+ | ` appName ` | ` string ` | Unique app name |
28
+ | ` code ` | ` string ` | Initial code for the cell |
29
+ | ` onAOProcess ` | ` (pid:string) => void ` | Callback function that run whenever a process is is loaded |
30
+ | ` onNewMessage ` | ` (msgs: msg[]) => void ` | Callback function, runs whenever process gets new messages |
31
+ | ` onInbox ` | ` (inbox: msg[]) => void ` | Callback function, runs whenever Inbox is received after calling ` getInbox() ` |
32
+ | ` width ` | ` string ` | Width of the cell |
33
+ | ` height ` | ` string ` | Height of the cell |
34
+ | ` className ` | ` string ` | Class names for styling |
35
+ | ` style ` | ` React.CSSProperties ` | Inline styles |
36
+ | ` devMode ` | ` boolean ` | Boolean to enable dev mode |
37
+
38
+
39
+ ### ` getInbox(...) `
40
+
41
+ Fetches latest Inbox messages from the process.
42
+
43
+ #### Arguments
44
+
45
+ | Argument | Type | Description |
46
+ | --------- | --------- | -------------------------- |
47
+ | ` cellId ` | ` string ` | Unique id of the cell |
48
+ | ` devMode ` | ` boolean ` | Boolean to enable dev mode |
35
49
36
50
### ` setCellCode(...) `
37
51
@@ -66,19 +80,25 @@ import { CodeCell } from '@betteridea/codecell';
66
80
cellId= " 1" // any unique cell id
67
81
appName= " BetterIDEa-Code-Cell" // Your unique app name
68
82
code= " print('Portable code cell ftw!')" // initial code (optional)
69
- onAOProcess= {(pid ) => console .log (" using process: " ,pid)} // print the process id whenever it loads
83
+ onAOProcess= {(pid ) => console .log (" using process: " , pid)} // print the process id whenever it loads
84
+ onNewMessage= {(msgs ) => console .log (" new messages: " , msgs)} // print new messages
85
+ onInbox= {(inbox ) => console .log (" got inbox: " , inbox)} // print inbox messages
70
86
/ >
71
87
```
72
88
73
89
To update the cell with a different code snippet, you can use the ` setCellCode ` function.
74
90
75
91
``` javascript
76
- import { setCellCode } from ' @betteridea/codecell' ;
92
+ import { setCellCode , getInbox } from ' @betteridea/codecell' ;
77
93
78
94
...
79
95
80
96
// This will update the code in the cell with the id provided
81
97
setCellCode (" 1" , " print('Updated code!')" );
98
+
99
+ // This will fetch the latest inbox messages from the process
100
+ getInbox (" 1" );
101
+ // as soon as the inbox is received, onInbox callback will be called
82
102
```
83
103
84
104
<details >
0 commit comments