-
Notifications
You must be signed in to change notification settings - Fork 18
Implementing Observables shim, issue #59 #62
Conversation
Also, I should note.. I talked with @matt-gadd about the fact that our interface calls a property |
Current coverage is 97.04% (diff: 100%)@@ master #62 diff @@
==========================================
Files 29 30 +1
Lines 1129 1287 +158
Methods 23 24 +1
Messages 0 0
Branches 211 248 +37
==========================================
+ Hits 1091 1249 +158
Misses 21 21
Partials 17 17
|
OK don't review this just yet.. I ran against the tests that Ant mentioned and I've got some things to fix up first :) |
OK. Refactored quite a bit... All the ES spec tests pass now!
|
A couple of notes, The ES spec tests have some pretty specific requirements about properties being non-enumerable, and certain object prototypes being I was wondering if you guys knew of an approach where I could use a static prototype, but still have certain internal variables ( |
Current coverage is 97.04% (diff: 100%)@@ master #62 diff @@
==========================================
Files 29 30 +1
Lines 1129 1285 +156
Methods 23 24 +1
Messages 0 0
Branches 211 248 +37
==========================================
+ Hits 1091 1247 +156
Misses 21 21
Partials 17 17
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lost of else
, else if
and catch
's that need to be on a new line.
*/ | ||
function startSubscription<T>(executor: Subscriber<T>, observer: Observer<T>): Subscription { | ||
let closed = false; | ||
let cleanUp: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can type cleanUp
to the union type return of the executor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So cleanUp
is either undefined
or a method with no parameters and no return value, so I've typed it as such (not just the return value of executor
).
else if (result && 'unsubscribe' in result) { | ||
cleanUp = result.unsubscribe; | ||
} | ||
else if (result !== undefined && result !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it just be (result)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not.. if the return value is undefined
or null
, no error. But if the return value is the number 0
or false
, we want to error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
} else { | ||
throw new TypeError('Observer.complete is not a function'); | ||
} | ||
} else if (cleanUpError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line for else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And else
above ^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed all those :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one @rorticus
Type: feature
Description:
Shim implementation of ES observables spec. Non-spec functionality (i.e.,
toPromise
,map
,filter
) will go in core.Related Issue: #59
Please review this checklist before submitting your PR: