Permalink
Browse files

d

  • Loading branch information...
youngjay committed May 26, 2013
1 parent 0fd77fe commit de8ed0fec305ef899f1547cbc786f1ec6f13dce6
Showing with 17 additions and 21 deletions.
  1. +7 −3 lib/index.js
  2. +6 −14 lib/promise.js
  3. +4 −4 test/rx.js
View
@@ -3,9 +3,13 @@ var PreservedEvent = require('./preserved-event')
var Event = require('./event');
module.exports = {
- Event: Event,
- PreservedEvent: PreservedEvent,
- Promise: Promise,
+ createEvent: function() {
+ return new Event();
+ },
+
+ createPreservedEvent: function() {
+ return new PreservedEvent();
+ },
then: function(fn) {
return new Promise(fn);
View
@@ -47,29 +47,21 @@ var PromiseInterFace = Subscribable.extend({
pick: function() {
var keys = slice.call(arguments);
- return this.thenCallback(function(args, callback) {
- if (args.length) {
- callback.apply(null, args.map(function(o) {
- return _.pick.apply(_, [o].concat(keys));
- }))
- } else {
- callback();
- }
+ return this.thenCallback(function(args, callback) {
+ callback.apply(null, args.map(function(o) {
+ return _.pick.apply(_, [o].concat(keys));
+ }))
});
},
pluck: function(key) {
return this.thenCallback(function(args, callback) {
- if (args.length) {
- callback.apply(null, _.pluck(args, key));
- } else {
- callback();
- }
+ callback.apply(null, _.pluck(args, key));
});
},
done: function() {
- return this.subscribe(noop)
+ return this.subscribe(noop);
}
})
.mixStatic({
View
@@ -29,8 +29,8 @@ describe('rx', function() {
function() {
var self = this;
- this.loadEvent = new Event();
- this.idEditEvent = new Event();
+ this.loadEvent = rx.createPreservedEvent();
+ this.idEditEvent = rx.createPreservedEvent();
this.idChangeEvent = rx.when(this.idEditEvent).then(function(evt, callback) {
@@ -91,7 +91,7 @@ describe('rx', function() {
var m, load;
beforeEach(function() {
m = new Model;
- load = new Event();
+ load = rx.createEvent();
m.setLoadEvent(load);
})
@@ -172,7 +172,7 @@ describe('rx', function() {
expect(spy).to.be.calledWith(0);
- var idEditEvent = new Event();
+ var idEditEvent = rx.createEvent();
m.setIdEditor(idEditEvent);

0 comments on commit de8ed0f

Please sign in to comment.