Using ember.js where you probably shouldn't


But where you can and you should.

Demo!


  1. Find willing victim participant
  2. Read brain data
  3. ...

What is Octopus?


Web based biometrics platform that:

  • Records
  • Visualizes
  • Stores
  • Analyses

all your biometric data for the purpose of:

  • Research
  • Medical
  • Marketing
  • Business!!111

How it works...

Show me the code!


# send a message to the control busbus.send('start_streaming').then (data) =>
  graph.startStreaming()

# implementation of findQuery in ember-modelfindQuery: (klass, records, params) ->
  request = {
    type: klass.constructor.toString(),
    params: params
  }
  
  bus.send('repository', request).then (data) =>
    @didFindQuery klass, records, data

url: 'ws://localhost:8000/control'
callbacks: [] connect: -> @ws = new WebSocket(url) @ws.onmessage = (evt) => @onMessage(evt.data)

send: (message_type, message = {}) ->   # assign a message id   d = new Date()   d.setHours(0,0,0,0)   msSinceMidnight = new Date() - d   message.id = "" + msSinceMidnight   message.message_type = message_type   deferred = @next(message)   @ws.sendJson(message)   deferred

onMessage: (data) ->
  @decode data, (callbackId, data) =>
    @dispatch(callbackId, data)

decode: (data, onDecode) ->
  return @decodeString(data, onDecode) if @isString(data)
  return @decodeBlob(data, onDecode) if data instanceof Blob

dispatch: (callbackId, response) ->
  deferred = @callbacks[callbackId]
  delete @callbacks[callbackId]
  deferred.resolve(response)

decodeString: (string, onDecode) ->
  parsed = JSON.parse(string)
  console.debug parsed
  onDecode(parsed.id, parsed) 
decodeBlob: (blob, onDecode) ->

  fileReader = new FileReader()
  fileReader.onload = ->
    arrayBuffer = @result

    dataView = new DataView(arrayBuffer, 0, 4)
    callbackId = "" + dataView.getUint32(0, false)

    onDecode(callbackId, new DataView(arrayBuffer, 4))

  fileReader.readAsArrayBuffer blob  





Why?


Thanks!


  • @jonnii
  • @jbrukh
  • @ivan_bezdomny 
  • @octopusmetrics

Ember.js

By Jonathan Goldman

Ember.js

  • 1,588