Skip to content

Instantly share code, notes, and snippets.

@ryanbrubaker
Created June 5, 2012 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbrubaker/2872411 to your computer and use it in GitHub Desktop.
Save ryanbrubaker/2872411 to your computer and use it in GitHub Desktop.
CommunicationLine model for morse code demo
class CommunicationLine extends Backbone.Model
initialize: (options) =>
@inputQueue = []
@communicationLine =
['', '', '', '', '', '', '', '', '', '']
@decoder = options.decoder
setInterval(@moveDataOneStep, 100)
addToken: (token) =>
@inputQueue.push(token)
moveDataOneStep: =>
@decoder.processToken(@communicationLine.pop())
nextToken = @inputQueue.shift()
@communicationLine.unshift(
if undefined == nextToken then '' else nextToken)
@trigger('hasNewData', @communicationLine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment