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

Should accept a Measure #4

Open
varna opened this issue Jul 23, 2019 · 2 comments
Open

Should accept a Measure #4

varna opened this issue Jul 23, 2019 · 2 comments

Comments

@varna
Copy link
Owner

varna commented Jul 23, 2019

Use case example:

  const imperial = store.state.settings.measure_system == 2;
  const units = imperial ? ["ac", "ft2"] : ["ha", "a"];
  const measure = measureFrom(...units);
  return measure(new Measure(value, "ha").to("m2"));

I would be cool to drop the .to("m2") part by accepting Measure (not only number of base type).

@varna
Copy link
Owner Author

varna commented Aug 23, 2019

Example of computed converter being used atm:

get () {
  return new Measure(this.value, 'm').to('km')
}
set (value: number) {
  this.value = new Measure(value, 'km').to('m')
}

Idea as replacement:

get () {
  return new Measure(this.value, 'm').to('km')
}
set (value: Measure) {
  this.value = new Measure(value, 'm')
}

@varna varna changed the title measureFrom should also accept a Measure Should accept a Measure Aug 29, 2019
@varna
Copy link
Owner Author

varna commented Aug 29, 2019

I might need to drop class approach. Prop overloading, constructor and value on this doesn't work that well together.

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