@@ -12,13 +12,13 @@ processes. When you update that object, it updates the equivalent accordingly. A
12
12
also delete the equivalent. This works both ways, so if you change the equivalent object in a subprocess, the original
13
13
will be changes as well.
14
14
15
- # Install
15
+ ## Install
16
16
17
17
``` shell
18
18
npm i ipos
19
19
```
20
20
21
- # Usage
21
+ ## Usage
22
22
23
23
In the main process:
24
24
@@ -51,7 +51,7 @@ See [`example/main-process.js`](https://github.com/drinking-code/inter-process-o
51
51
and [ ` example/sub-process.js ` ] ( https://github.com/drinking-code/inter-process-object-sharing/blob/main/example/sub-process.js )
52
52
.
53
53
54
- ## A note on class instances
54
+ ### A note on class instances
55
55
56
56
To synchronise class instances, you first have to register the class with ipos _ on each process_ (on which the class
57
57
instance does not yet exist) before the synchronisation happens. That means if you want to connect two IPOS instances,
@@ -106,12 +106,12 @@ const ipos = IPOS.registerClass(Example)
106
106
const ipos = await IPOS .new ()
107
107
```
108
108
109
- ## ` IPOS() `
109
+ ### ` IPOS() `
110
110
111
111
The main class. Don't use the ` new ` keyword (when creating an instance in a subprocess). Instead, use the
112
112
static [ ` IPOS.new() ` ] ( #static-iposnew-ipos--promiseipos ) method to create an instance.
113
113
114
- ### ` static IPOS.new(): IPOS | Promise<IPOS> `
114
+ #### ` static IPOS.new(): IPOS | Promise<IPOS> `
115
115
116
116
Creates a new instance. Multiple instances are not yet supported, so only create one instance per process.
117
117
@@ -121,7 +121,7 @@ Creates a new instance. Multiple instances are not yet supported, so only create
121
121
- ` Promise<IPOS> ` , if called in a subprocess.
122
122
Use await to wait for the connection to the main process to be established.
123
123
124
- ### ` ipos.addProcess(process: ChildProcess): Promise<void> `
124
+ #### ` ipos.addProcess(process: ChildProcess): Promise<void> `
125
125
126
126
Connect a subprocess to the IPOS instance. The subprocess must also
127
127
call [ ` IPOS.new() ` ] ( #static-iposnew-ipos--promiseipos ) for the two processes' IPOS to connect.
@@ -133,7 +133,7 @@ call [`IPOS.new()`](#static-iposnew-ipos--promiseipos) for the two processes' IP
133
133
134
134
** Returns:** ` Promise<void> ` . Use await to wait for the connection to the subprocess to be established.
135
135
136
- ### ` ipos.removeProcess(process: ChildProcess): boolean `
136
+ #### ` ipos.removeProcess(process: ChildProcess): boolean `
137
137
138
138
Disconnect a subprocess to the IPOS instance. Closed subprocess automatically get disconnected.
139
139
@@ -145,7 +145,7 @@ Disconnect a subprocess to the IPOS instance. Closed subprocess automatically ge
145
145
** Returns:** ` boolean ` . ` true ` if a process was connected and has been disconnected, or ` false ` if the process was not
146
146
connected.
147
147
148
- ### ` ipos.create(key: string, value: any) `
148
+ #### ` ipos.create(key: string, value: any) `
149
149
150
150
Create a field on the IPOS instance. This value can later be accessed or updated (See
151
151
[ ` ipos.get() ` ] ( #iposgetkey-string-any ) ). After creating a field, you can access and update it (even change the type)
@@ -164,7 +164,7 @@ console.log(sharedObject.myValue) // -> 'foo'
164
164
- ` key: string ` A unique key.
165
165
- ` value: any ` The value to be stored.
166
166
167
- ### ` ipos.get(key: string): any `
167
+ #### ` ipos.get(key: string): any `
168
168
169
169
Get an already created field from the IPOS instance. You can also use ` ipos[key: string] ` to access the value. If you
170
170
use a method on the value that changes the value, this change will also be reflected in the connected IPOS instances.
@@ -189,7 +189,7 @@ console.log(sharedObject.myArray) // -> ['myString']
189
189
190
190
** Returns:** ` any ` . The stored value.
191
191
192
- ### ` ipos.delete(key: string): boolean `
192
+ #### ` ipos.delete(key: string): boolean `
193
193
194
194
Deletes the field with the specified key.
195
195
@@ -199,9 +199,9 @@ Deletes the field with the specified key.
199
199
200
200
** Returns:** ` boolean ` . ` true ` if a field existed and has been removed, or ` false ` if the element does not exist.
201
201
202
- # Testing
202
+ ## Testing
203
203
204
- ## Glossary of terms
204
+ ### Glossary of terms
205
205
206
206
- ** "Synchronise"** a field: _ Creating a main instance, then adding a field before connecting to a child instance._ The
207
207
field will be transmitted along with any other fields that may have been created during the connection process
0 commit comments