enterAuditorium

Admits a finite number of people into the event hall. Once in, they are ushered in pairs by the first available usher

enterAuditorium
Parameters
people (Number) number of people to admit into the event hall at this point in time
Returns
Promise:

getNextNumberToAdmit

When trying to admit people into the hall, this helps us keep track of the seating capacity as well as total number admitted so far. We only attempt to admit 16 at a time or just the number needed to no exceed the seating capacity

getNextNumberToAdmit
Returns
Number:

personsToEnter

Determines the next valid number of people to admit into the hall

personsToEnter
Returns
Number:

admitPeople

Relies on personsToEnter to recursively admit only the next valid number of people into the event hall

admitPeople
Returns
Promise:

arrangeSeating

Simulates arranging the seating space. We actually only create the 500 row nodes, and delay creating the seat nodes until an attendee needs to be seated. This helps ensure we don't start the app with 8k seat nodes in the DOM

Each side has 250 rows and both contain a row-0 (the first row) and up to a row-249 (the last row)

arrangeSeating
Returns
Promise:

findUshersForEvent

Source for 2 to 6 ushers for any given event

findUshersForEvent
Returns
Array: An array of ushers

getAuditoriumReady

Secures a list of ushering staff, and prepares the seating space

getAuditoriumReady
Returns
Promise:

Attendee

An object represnting an attendee in the system

new Attendee(id: String)

Extends Person

Parameters
id (String) the unique user id for this attendee
Instance Members
goGetSeated(whereToSeat)

Person

An object represneting a person actor (usher or event attendee) in the system

new Person(id: String)
Parameters
id (String)
Instance Members
getId()
getAttention()

Usher

An object representing an usher in the system

new Usher(id: String, hallSpec: Object)

Extends Person

Parameters
id (String) the unique user id for this usher
hallSpec (Object) an object with represnting the specs of the event hall
Instance Members
usherToSeat(attendees)

Ushering

Coordinate "provisioning" ushers and figuring out which of them is ready to admit attendees when the system needs to do so

new Ushering(spec: Object)
Parameters
spec (Object)
Instance Members
getWhoIsAvailable()

rAF

Promise-ified shorthand for requestAnimationframe

rAF
Parameters
opts (Object = {}) contains waitUntil that indicates any initial wait time before getting the next frame
Returns
Promise: a promise that resolve when the then frame is available

rAFQueue

Schedules a number of ui/render tasks (no-arg functions) to be called sequentially by requestAnimationFrame. Useful when you want to do a large number of ui/dom operations and need to keep the operations performant.

rAFQueue
Parameters
fns (Function) variable number of functions representing the ui/render tasks to queue with requestAnimationFrame
Returns
Promise: a promise that resolves after executing all tasks in the queue

intFromId

Returns the int portion of the given id

intFromId
Parameters
id (String) id of a person in the system
Returns
Number:

select

Shorthand for document.querySelector

select
Returns
Node:

selectAll

Shorthand for document.querySelectorAll

selectAll
Returns
NodeList:

pairsFrom

A special interator/iterable that allows you to loop over the items of an array in pairs

const list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
for(let pair of pairsFrom(list)) {
 // pair will be [1, 2], [3, 4] e.t.c
}

We used this to provide a pair of attendees to an usher at a given time

pairsFrom
Parameters
array (array = []) the array to iterate over
Returns
Iterator:

isEven

Determines if a number is even (returns true) or not (returns false)

isEven
Parameters
num (Number) number to check
Returns
Boolean:

random

Generates a random number somewhere between min and max properties of the parameter. I basically lifted this from Stackoverflow :)

random
Parameters
param0 (Object) object with min and max property indicating rough range of the number to generate
Name Description
param0.max any
param0.min any (default 1)
Returns
Number:

logr

A handly util for better formatted console.log statements

logr
Parameters
realm (String) Designates a sub-system of this app emitting the log messages. Imagine logs from the UI vs logs from a service worker. These are seen as diffrent realms!
Returns
Object: an object with info , error , and warn fields used to handle that specific kind of log messages