Added disconnect method#14
Conversation
…orage being removed.
Codecov Report
@@ Coverage Diff @@
## master #14 +/- ##
==========================================
+ Coverage 97.22% 97.75% +0.53%
==========================================
Files 1 1
Lines 72 89 +17
==========================================
+ Hits 70 87 +17
Misses 2 2
Continue to review full report at Codecov.
|
index.js
Outdated
| } | ||
|
|
||
| function create (data, cb) { | ||
| if (_disconnected) return cb(new Error('disconnected')) |
There was a problem hiding this comment.
those callbacks should be called after setImmediate(), a callback shouldn't be called in the same tick as its function is invoked
There was a problem hiding this comment.
I thought so too but on other places it also immediately returned (when in rome...). I took the liberty to fix all occurrences: c621c09
|
|
||
| var store = toilet('state.json') | ||
| multidrive(store, createArchive, noop, function (err, drive) { | ||
| multidrive(store, createArchive, noopCb, function (err, drive) { |
There was a problem hiding this comment.
this requirement to call the cb in closeArchive needs to be documented
There was a problem hiding this comment.
To be honest I am a bit puzzled about this request. closeArchive was always supposed to call the callback (that didn't change) the only thing that changes is that closeArchive is now needed in some tests in order to disconnect the drives. The only way I found this necessary to be documented was in the readme: 594dc31
|
@juliangruber Thank you for the review. I pushed a few changes. |
|
Thanks Martin! Published as 5.2.0 |
In order to properly shut down hyperdrives (Ctrl+C) it is good to have a disconnect method that disconnects all the archives (and networks) for a clean closing of an application. (Note: this is also quite useful for clean unit tests)