Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Event Bus
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libero
Event Bus
Commits
fd47a0b9
Commit
fd47a0b9
authored
5 years ago
by
Peter Hooper
Browse files
Options
Downloads
Patches
Plain Diff
Add missing files for definition of Event
parent
d59f3944
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/event-bus/event.test.ts
+24
-0
24 additions, 0 deletions
src/event-bus/event.test.ts
src/event-bus/event.ts
+17
-0
17 additions, 0 deletions
src/event-bus/event.ts
with
41 additions
and
0 deletions
src/event-bus/event.test.ts
0 → 100644
+
24
−
0
View file @
fd47a0b9
import
{
Event
}
from
'
./event
'
;
describe
(
'
Event class
'
,
()
=>
{
const
create
=
(
T
,
type
,
payload
):
Event
=>
new
T
(
type
,
payload
);
it
(
'
initialises members
'
,
()
=>
{
const
x
=
create
(
Event
,
'
test
'
,
'
some-payload
'
);
expect
(
x
.
id
).
toHaveLength
(
41
);
expect
(
x
.
created
instanceof
Date
).
toBeTruthy
();
expect
(
x
.
created
.
toISOString
()).
toHaveLength
(
24
);
expect
(
x
.
eventType
).
toBe
(
'
test
'
);
expect
(
x
.
payload
).
toBe
(
'
some-payload
'
);
});
it
(
'
has correct members
'
,
()
=>
{
const
keys
=
Object
.
keys
(
create
(
Event
,
'
test
'
,
'
payload
'
));
expect
(
keys
).
toHaveLength
(
4
);
expect
(
keys
).
toContain
(
'
id
'
);
expect
(
keys
).
toContain
(
'
created
'
);
expect
(
keys
).
toContain
(
'
eventType
'
);
expect
(
keys
).
toContain
(
'
payload
'
);
});
});
This diff is collapsed.
Click to expand it.
src/event-bus/event.ts
0 → 100644
+
17
−
0
View file @
fd47a0b9
import
{
v4
as
uuid
}
from
'
uuid
'
;
import
{
EventType
}
from
'
./types
'
;
/**
* Event - Used in this abstract form throughout this library.
* It is abstract so you cannot create an instance of it - derived Event types
* and their associated Payload types are the responsibility of the caller.
*/
export
abstract
class
Event
{
readonly
id
:
string
;
readonly
created
:
Date
;
constructor
(
readonly
eventType
:
EventType
,
readonly
payload
:
object
)
{
this
.
id
=
eventType
.
toString
()
+
'
_
'
+
uuid
();
this
.
created
=
new
Date
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
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