-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add event machinery and global script arguments handling (#57)
- Loading branch information
1 parent
6c817f8
commit b344657
Showing
7 changed files
with
231 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { LinkedList, LinkedListNode } from '../../utils'; | ||
|
||
import EventType from './EventType'; | ||
import FrameScriptObject from './FrameScriptObject'; | ||
|
||
class EventListenerNode extends LinkedListNode { | ||
listener: FrameScriptObject; | ||
|
||
constructor(listener: FrameScriptObject) { | ||
super(); | ||
|
||
this.listener = listener; | ||
} | ||
} | ||
|
||
class EventEmitter { | ||
type: EventType; | ||
listeners: LinkedList<EventListenerNode>; | ||
unregisterListeners: LinkedList<EventListenerNode>; | ||
registerListeners: LinkedList<EventListenerNode>; | ||
signalCount: number; | ||
pendingSignalCount: number; | ||
|
||
constructor(type: EventType) { | ||
this.type = type; | ||
this.listeners = LinkedList.using('link'); | ||
this.unregisterListeners = LinkedList.using('link'); | ||
this.registerListeners = LinkedList.using('link'); | ||
this.signalCount = 0; | ||
this.pendingSignalCount = 0; | ||
} | ||
|
||
get name() { | ||
return this.type; | ||
} | ||
} | ||
|
||
export default EventEmitter; | ||
export { EventListenerNode }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enum EventType { | ||
FRAMES_LOADED = 'FRAMES_LOADED', | ||
SET_GLUE_SCREEN = 'SET_GLUE_SCREEN' | ||
} | ||
|
||
export default EventType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters