-
-
Notifications
You must be signed in to change notification settings - Fork 657
fix: add typings for event stream and fix bugs that surfaced #5290
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
Conversation
00c4626
to
3cf59c5
Compare
3cf59c5
to
acce897
Compare
if (filters.indexOf(filterExpr) < 0) { | ||
filters.push(filterExpr); | ||
} | ||
return on; |
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 had to add this to make the typings correct. Does JavaScript magically return the first argument here or does reduce have some other magic behavior?
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.
No, nothing magic. Just a (somewhat lazy) re-appropriation of a reduce
when a forEach
would suffice (reusing the method to be reduce duplication of error checks for evt.between
).
@@ -13,7 +13,7 @@ const clear: TransformCompiler = { | |||
|
|||
parse: (model, selDef, selCmpt) => { | |||
if (selDef.clear) { | |||
selCmpt.clear = parseSelector(selDef.clear, 'scope'); | |||
selCmpt.clear = isString(selDef.clear) ? parseSelector(selDef.clear, 'scope') : selDef.clear; |
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.
The check for string was missing here.
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 catch! Thanks!
events(selCmpt, (_: OnEvent[], evt: EventStream) => { | ||
const filters = evt.between[0].filter || (evt.between[0].filter = []); | ||
events(selCmpt, (on: OnEvent[], evt: Stream) => { | ||
const filters = array(evt.between[0].filter || (evt.between[0].filter = [])); |
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.
We previously assumed that filter is an array. Was this assumption correct?
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.
Yes, once filters have been parsed by vega-event-selector
, this property will always be an array.
acce897
to
63f3f1e
Compare
63f3f1e
to
423811c
Compare
Blocked by vega/ts-json-schema-generator#192 |
423811c
to
27a59f0
Compare
Instead of blocking on vega/ts-json-schema-generator#192, I sent vega/vega#1926. |
d2e8c5b
to
ccd8209
Compare
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.
LGTM. Thanks @domoritz!
events(selCmpt, (_: OnEvent[], evt: EventStream) => { | ||
const filters = evt.between[0].filter || (evt.between[0].filter = []); | ||
events(selCmpt, (on: OnEvent[], evt: Stream) => { | ||
const filters = array(evt.between[0].filter || (evt.between[0].filter = [])); |
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.
Yes, once filters have been parsed by vega-event-selector
, this property will always be an array.
if (filters.indexOf(filterExpr) < 0) { | ||
filters.push(filterExpr); | ||
} | ||
return on; |
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.
No, nothing magic. Just a (somewhat lazy) re-appropriation of a reduce
when a forEach
would suffice (reusing the method to be reduce duplication of error checks for evt.between
).
@@ -13,7 +13,7 @@ const clear: TransformCompiler = { | |||
|
|||
parse: (model, selDef, selCmpt) => { | |||
if (selDef.clear) { | |||
selCmpt.clear = parseSelector(selDef.clear, 'scope'); | |||
selCmpt.clear = isString(selDef.clear) ? parseSelector(selDef.clear, 'scope') : selDef.clear; |
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 catch! Thanks!
Fixes #5289