-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-fix isObservable() and add test - fixes #29 #30
Conversation
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.
Change the name to lib/utils.js
import {isListr, isObservable} from '../lib/util'; | ||
|
||
test('isListr', t => { | ||
t.falsy(isListr(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.
Use t.false
and t.true
.
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.
Initially I did. But it failed, since right now isListr()
will return null
or the listr instance itself if it is. So then I just added a ... ? true : false
to isListr()
, but xo
failed, because for some weird reason it complains that the ternary is superfluous...
Any suggestions?
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.
Wrap it in Boolean(...)
@@ -0,0 +1,8 @@ | |||
'use strict'; | |||
|
|||
const isListr = obj => obj && obj.setRenderer && obj.add && obj.run; |
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.
Export the function right away without intermediate step.
Fixed the code 👍 |
Can you rename |
Sweet! Thanks for looking into this @andywer 🍻 ! |
@SamVerschueren No problem 🙌 |
This actually breaks the stuff that I'm working on because of the changes to |
@TylorS I'm not interested to actually support all the possible observable-like implementations out there. The reason I use duck-typing currently is because of an issue with is-observable which uses |
@TylorS @SamVerschueren I can understand both your standpoints. I had a quick look and So how about that: We check with the current custom logic and fallback to PS: I can also open an issue on |
Let's discuss this further in #31 |
Moved
isListr
andisObservable
into a separateutil.js
and added a unit test for theutil.js
. Verifies thatisObservable()
works with bothrxjs/Observable
andzen-observable
.isObservable()
checks forobj.constructor.name === 'Observable'
now. Still somewhat hacky, but at least a plausible way to go as long as there's no official solution.Btw: Maybe propose this to sindresorhus/is-observable#1?