Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
workerbee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
workerbee
Commits
c1df63fe
Verified
Commit
c1df63fe
authored
4 months ago
by
Mateusz Tyszczak
Browse files
Options
Downloads
Patches
Plain Diff
Hide EventEmitter internals from the end-user
parent
6194a77a
No related branches found
No related tags found
1 merge request
!23
Dependencies-related work
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/bot.ts
+0
-25
0 additions, 25 deletions
src/bot.ts
src/interfaces.ts
+22
-38
22 additions, 38 deletions
src/interfaces.ts
with
22 additions
and
63 deletions
src/bot.ts
+
0
−
25
View file @
c1df63fe
...
...
@@ -40,31 +40,6 @@ export const DEFAULT_WORKERBEE_OPTIONS = {
export
const
DEFAULT_BLOCK_INTERVAL_TIMEOUT
=
1500
;
interface
IWorkerBeeEvents
{
"
stop
"
:
()
=>
void
|
Promise
<
void
>
;
"
start
"
:
()
=>
void
|
Promise
<
void
>
;
"
block
"
:
(
blockData
:
IBlockData
)
=>
void
|
Promise
<
void
>
;
"
transaction
"
:
(
transactionData
:
ITransactionData
)
=>
void
|
Promise
<
void
>
;
"
error
"
:
(
error
:
WorkerBeeError
)
=>
void
|
Promise
<
void
>
;
}
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export
declare
interface
WorkerBee
{
on
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
once
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
off
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
}
/* eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging */
export
class
WorkerBee
extends
EventEmitter
implements
IWorkerBee
{
public
running
:
boolean
=
false
;
...
...
This diff is collapsed.
Click to expand it.
src/interfaces.ts
+
22
−
38
View file @
c1df63fe
import
type
EventEmitter
from
"
events
"
;
import
type
{
IBeekeeperUnlockedWallet
}
from
"
@hiveio/beekeeper
"
;
import
type
{
ApiAccount
,
ApiBlock
,
ApiTransaction
,
IHiveChainInterface
,
ITransaction
,
operation
}
from
"
@hiveio/wax
"
;
import
type
{
Subscribable
}
from
"
rxjs
"
;
import
type
{
IStartConfiguration
}
from
"
./bot
"
;
import
type
{
WorkerBeeError
}
from
"
./errors
"
;
export
interface
IBlockData
{
number
:
number
;
...
...
@@ -64,7 +64,7 @@ export interface IQueenBee {
export
interface
IBroadcastOptions
{
/**
* Can be either absolute time that will be passed to the
{@link
Date
}
constructor
* Can be either absolute time that will be passed to the Date constructor
* or relative time, like: "+10s", "+2m", "+1h"
*
* @type {string | number | Date}
...
...
@@ -73,7 +73,15 @@ export interface IBroadcastOptions {
throwAfter
?:
string
|
number
|
Date
;
}
export
interface
IWorkerBee
extends
EventEmitter
{
export
interface
IWorkerBeeEvents
{
"
stop
"
:
()
=>
void
|
Promise
<
void
>
;
"
start
"
:
()
=>
void
|
Promise
<
void
>
;
"
block
"
:
(
blockData
:
IBlockData
)
=>
void
|
Promise
<
void
>
;
"
transaction
"
:
(
transactionData
:
ITransactionData
)
=>
void
|
Promise
<
void
>
;
"
error
"
:
(
error
:
WorkerBeeError
)
=>
void
|
Promise
<
void
>
;
}
export
interface
IWorkerBee
{
readonly
running
:
boolean
;
readonly
configuration
:
Readonly
<
IStartConfiguration
>
;
...
...
@@ -123,41 +131,17 @@ export interface IWorkerBee extends EventEmitter {
*/
[
Symbol
.
asyncIterator
]():
AsyncIterator
<
IBlockData
>
;
/**
* Triggers on any bot start
*
* @param event event name
* @param handler handler to be called before automation start
*/
on
(
event
:
"
start
"
,
handler
:
()
=>
void
):
this
;
/**
* Triggers on any bot stop
*
* @param event event name
* @param handler handler to be called after complete stop of the automation
*/
on
(
event
:
"
stop
"
,
handler
:
()
=>
void
):
this
;
/**
* Triggers on any bot-related error
*
* @param event event name
* @param handler handler to be called on error event
*/
on
(
event
:
"
error
"
,
handler
:
(
error
:
Error
)
=>
void
):
this
;
/**
* Triggers on new block detected
*
* @param event event name
* @param handler handler to be called on new block event
*/
on
(
event
:
"
block
"
,
handler
:
(
data
:
IBlockData
)
=>
void
):
this
;
/**
* Triggers on new transaction detected
*
* @param event event name
* @param handler handler to be called on new block event
*/
on
(
event
:
"
transaction
"
,
handler
:
(
data
:
ITransactionData
)
=>
void
):
this
;
on
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
once
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
off
<
U
extends
keyof
IWorkerBeeEvents
>
(
event
:
U
,
listener
:
IWorkerBeeEvents
[
U
]
):
this
;
}
export
interface
IWorkerBeeConstructor
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment