Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

Should 'd3.scala' be a trait rather than object? #28

Open
twrichards opened this issue Jan 4, 2017 · 2 comments
Open

Should 'd3.scala' be a trait rather than object? #28

twrichards opened this issue Jan 4, 2017 · 2 comments

Comments

@twrichards
Copy link

I had need recently to extend your library to use an additional D3 library however I couldn't 'Monkey Patch' your facade (as per https://www.scala-js.org/doc/interoperability/facade-types.html) as 'd3.scala' is an object and therefore not extendable.

Jquery (the example used in the ScalaJS documentaion) uses a trait which means it can be extended nicely.

Is there a reason d3 is an object?

PS; thanks for the awesome lib :)

@spaced
Copy link
Owner

spaced commented Jan 10, 2017

thanks for your hint. because this part is over a year old. i tried to use annotations instead of doing some js.Dynamic magic. but your use case is very valid. I implemented the jquery approach. Have look at branch issue_28_trait_d3 https://github.com/spaced/scala-js-d3/tree/issue_28_trait_d3
does it helps?

@twrichards
Copy link
Author

thanks for your reply and your patch. Unfortunately in my environment I need to rely on the built repo version of 0.3.2 (because of my scala & sbt versions). I think you patch will help others though :)

I managed to get it working in my situation however; I used some implicit conversion magic: https://github.com/twrichards/emishviz/blob/master/client/src/main/scala/facades/d3/ImplicitAddons.scala - this allows me to call d3.slider() which will use my underlying implementation all other methods called on d3 object will use your impls. Neat right?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants