Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 1fec1ac

Browse files
committed
Added function for setting actions before init
1 parent bc1f5ac commit 1fec1ac

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ class ListingManager {
5050
this._lastInventoryUpdate = null;
5151
}
5252

53+
/**
54+
* Sets actions
55+
* @param {Object} actions
56+
* @param {Array<Object>} actions.create
57+
* @param {Array<Object>} actions.remove
58+
*/
59+
setActions (actions) {
60+
if (this.ready) {
61+
throw new Error('Can\'t set actions while ready');
62+
}
63+
64+
this.actions = actions;
65+
}
66+
5367
/**
5468
* Initializes the module
5569
* @param {Function} callback
@@ -84,6 +98,9 @@ class ListingManager {
8498
// Emit listings after initializing
8599
this.emit('listings', this.listings);
86100

101+
// Start processing actions if there are any
102+
this._processActions();
103+
87104
return callback(null);
88105
});
89106
});
@@ -370,7 +387,7 @@ class ListingManager {
370387
/**
371388
* Stops all timers and timeouts and clear values to default
372389
*/
373-
stop () {
390+
shutdown () {
374391
// Stop timers
375392
clearTimeout(this._timeout);
376393
clearInterval(this._heartbeatInterval);

0 commit comments

Comments
 (0)