Commit 3c51a3dbfcb5e55cfdcd0b54850b584f04b0f602
Merge pull request #2 from primea/new-api
New API (onCreation/onMessage/onStartup)wanderer authored on 7/27/2017, 10:17:58 PM
GitHub committed on 7/27/2017, 10:17:58 PM
Parent: abe94d07955c811f1fdb8e283515c3ec0309a104
Parent: 5f1ef8b77f428cd3ebef37c487314c5ef52acff2
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -10,16 +10,23 @@ | |||
10 | 10 … | // In general, a root instance receives no message, but every other instance | |
11 | 11 … | // receives a message with a singel port, which is a channel to its parent (aka the root). | |
12 | 12 … | // | |
13 | 13 … | // Optionally it can return a single value. | |
14 | - async initialize (message) { | ||
14 … | + async onCreation (message) { | ||
15 | 15 … | throw new Error('Unimplemented initialiser') | |
16 | 16 … | } | |
17 | 17 … | ||
18 … | + // This method runs when the container needs to be started up. It cannot be | ||
19 … | + // called before onCreation was successful. It can be called after a shutdown | ||
20 … | + // was requested in onIdle. | ||
21 … | + async onStartup () { | ||
22 … | + throw new Error('Unimplemented startup method') | ||
23 … | + } | ||
24 … | + | ||
18 | 25 … | // This is called for each incoming message the container gets. | |
19 | 26 … | // | |
20 | 27 … | // Optionally it can return a single value. | |
21 | - async run (message) { | ||
28 … | + async onMessage (message) { | ||
22 | 29 … | throw new Error('Unimplemented message: ' + message.data) | |
23 | 30 … | } | |
24 | 31 … | ||
25 | 32 … | // onIdle is called when there are no more immediate messages pending |
Built with git-ssb-web