Skip to content
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

remove d3.functor #1374

Closed
gordonwoodhull opened this issue Mar 22, 2018 · 1 comment
Closed

remove d3.functor #1374

gordonwoodhull opened this issue Mar 22, 2018 · 1 comment
Milestone

Comments

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Mar 22, 2018

We shouldn't modify the d3 namespace. Since d3 has dropped d3.functor we should either drop it or replace it.

I'm not sure of the rationale, but CHANGES.md recommends creating a constant() function instead

function constant(x) {
  return function() {
    return x;
  };
}

and replacing each call to d3.functor with

var fx = typeof x === "function" ? x : constant(x);

(We could create dc.constant() to make it available to our users.)

Perhaps it is marginally faster because the closure holding x has no code in it. Anyway, I think we should do this the idiomatic d3 way, even though it means breaking some user code.

Alternately we could implement dc.functor(), not use it internally, and immediately deprecate it, pointing to CHANGES.md for rationale. But it seems kind of silly to break user code and give a deprecated function as a quick fix.

@gordonwoodhull
Copy link
Contributor Author

Fixed in 3.0 alpha 8

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

No branches or pull requests

1 participant