Below are the details of the new features in this PR. Also included are checkboxes for things to be completed before the PR is ready to be reviewed and merged in.
Print Queue
There is now a printQueue attribute on the ActivityWatcher. This is passed into the watches getTicketObjects function, so that functions that do not immediately resolve (or take time to resolve) can add their tickets eventually. Most APIs do not immediately return values (simply put, asynchronous), so this printQueue can be interacted with when those APIs do get their values.
TLDR: Instead of returning ticket objects, put them on the printQueue.
/* old way */
getTicketObjects() {
return [{ /* ticket object */ }]
}
/* new way */
getTicketObjects( printQueue ) {
printQueue.unshift({ /* ticket object */ })
}
unshift is the javascript equivalent of enqueue
[x] Tests for getTicketObjects
[x] Tests to see that they get cleared on reset
[x] Tests to see that tickets are removed after printing
[x] Documentation in the README.md
Start
There is now a ActivityWatcher#start function, which starts all the watches, and creates a loop for the printers to check for new tickets in the printQueue. It has one parameter, the number of milliseconds to loop on for checking if there are new tickets.
[x] Tests for before starting
[x] Tests for after starting
[x] Documentation in the README.md
Watch Attributes
Tickets now include a watch attribute, containing a string, that is the name of the watch they came from.
Watches include a _interval attribute, which are added by the Activity Watcher in ActivityWatcher#addWatch, so that watches can be started later, in ActivityWatcher#start.
[x] Update Ticket spec in README.md
New Potential Issues
These issues may not be addressed in this PR, but are large chunks of work, or discussion, that should be worked on in other branches.
[x] Should watches and printers AFTER ActivityWatcher#start be included?
[x] Should tickets be removed from the printQueue if there are no printers?
[x] Should there be a default / test ticket for printers?
Below are the details of the new features in this PR. Also included are checkboxes for things to be completed before the PR is ready to be reviewed and merged in.
Print Queue
There is now a
printQueue
attribute on theActivityWatcher
. This is passed into the watchesgetTicketObjects
function, so that functions that do not immediately resolve (or take time to resolve) can add their tickets eventually. Most APIs do not immediately return values (simply put, asynchronous), so thisprintQueue
can be interacted with when those APIs do get their values.TLDR: Instead of returning ticket objects, put them on the
printQueue
.unshift is the javascript equivalent of enqueue
Start
There is now a
ActivityWatcher#start
function, which starts all the watches, and creates a loop for the printers to check for new tickets in theprintQueue
. It has one parameter, the number of milliseconds to loop on for checking if there are new tickets.Watch Attributes
Tickets now include a
watch
attribute, containing a string, that is the name of the watch they came from.Watches include a
_interval
attribute, which are added by the Activity Watcher inActivityWatcher#addWatch
, so that watches can be started later, inActivityWatcher#start
.New Potential Issues
These issues may not be addressed in this PR, but are large chunks of work, or discussion, that should be worked on in other branches.
ActivityWatcher#start
be included?printQueue
if there are no printers?