-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix gradient values #2384
fix gradient values #2384
Conversation
85bfa28
to
30e56c6
Compare
30e56c6
to
a800ac7
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.
Thanks for the PR! Looks good!
if let Some(view) = ctx.props().view.clone() && let Some(column_name) = ctx.props().column_name.clone() { | ||
ctx.link().send_future(async { | ||
let view = view.unchecked_into::<JsPerspectiveView>(); | ||
let min_max = view._get_min_max(column_name.into()).await.unwrap(); |
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 _
prefix in the extern "C"
functions is meant to indicate a place where the native wasm_bindgen
type support is insufficient, and that this method should not be made public or called directly. I would argue in this case that, as this function always returns the JavaScript-equivalent of a 2-tuple of f64
, that we should add fn get_min_max(col: &str) -> (f64, f64)
to the the impl JsPerspectiveView
block in perspective.js
extern module, such that consumers of this API need not juggle wasm_bindgen
typecasting magic as below at the callsite.
As a general principal I think, we want to try to contain wasm_bindgen
types to dedicated FFI/extern modules except in cases where it impacts performance.
self.config.bg_gradient = None; | ||
} | ||
}; | ||
|
||
self.dispatch_config(ctx); | ||
false | ||
} | ||
NumberColumnStyleMsg::DefaultGradientChanged(gradient) => { |
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.
Distributing the default value logic across multiple files like means we have the of the complexity of the default_config
/config
design, but none of the decoupling. We should instead IMO make the default_config()
getter an async method which can query it's container.
html_template! { | ||
<div class="item_title">{title.clone()}</div> | ||
<div class="style_contents"> | ||
<NumberColumnStyle { config } {default_config} {on_change} /> | ||
<NumberColumnStyle column_name={column_name.clone()} view={view.clone()} { config } {default_config} {on_change} /> |
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.
Don't bind and pass View
- pass the state object Session
and request the view immediately where needed. This doesn't matter as much for this change due to the ephemeral nature of this component, but for components that persist between query changes, View
can not only go stale, any remaining stale references will segfault if you try to call them.
Bugfix
Number style gradient values were not being populated. This uses the same code as an older version, but reimplemented in rust.
Testing
No tests were added or changed.
Screenshots (if appropriate)
Checklist
CONTRIBUTING.md
and followed its Guidelines