Permalink
Browse files

use new observable engine on uploader

  • Loading branch information...
1 parent f1aca98 commit 884e729998d6c854e13becc024036112c0d192f2 @wilkerlucio wilkerlucio committed Feb 24, 2012
Showing with 8 additions and 8 deletions.
  1. +5 −3 src/uploader.coffee
  2. +3 −5 test/src/uploader_test.coffee
View
@@ -1,8 +1,10 @@
-FileSafr.Uploader = Ember.Object.extend
- init: (options = {}) ->
+FileSafr.Uploader = class Uploader
+ mix @::, FileSafr.Observable
+
+ constructor: (options = {}) ->
# listen to all events (options that starts with "on")
for opt, fn of options
- Ember.addListener(this, opt, fn) if opt.match(/^on/)
+ @addListener(match[1], fn) if match = opt.match(/^on(.+)/)
upload: (targetUrl, formData) ->
xhr = new XMLHttpRequest()
@@ -8,8 +8,6 @@ test "initialization add event listeners", ->
onprogress: -> null
other: -> null
- events = Ember.metaPath(uploader, ["listeners"], true)
-
- ok events.oncomplete
- ok events.onprogress
- ok !events.other
+ equal uploader.listenersForEvent("complete").length, 1
+ equal uploader.listenersForEvent("progress").length, 1
+ equal uploader.listenersForEvent("other").length, 0

0 comments on commit 884e729

Please sign in to comment.