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

Positional sugar for operators that usually take one arg #230

Open
appsforartists opened this issue Oct 7, 2017 · 0 comments
Open

Positional sugar for operators that usually take one arg #230

appsforartists opened this issue Oct 7, 2017 · 0 comments

Comments

@appsforartists
Copy link
Member

appsforartists commented Oct 7, 2017

The named arguments pattern is great for functions that take multiple arguments. We moved all operators to it in #193. However, there are some operators that usually take a single argument; they have been made harder to read and to use by the transition.

Therefore, I'm going to go back and add positional sugar for operators with one primary argument:

  • added/subtracted/multiplied/dividedBy
  • distanceFrom
  • log
  • pluck
  • isAnyOf
  • rewriteTo
  • threshold
  • startWith
  • merge
  • appendUnit
  • _map
  • _tap
  • _filter
  • _slidingWindow

For consistency, they will keep their named argument signatures as the primary entry. The positional alternative is just sugar, because this:

translate$.distanceFrom({ x: 100, y: 100 }).threshold(70).isAnyOf([ ThresholdRegion.ABOVE ]).rewriteTo(100);

is easier to read and to write than:

translate$.distanceFrom({ origin: { x: 100, y: 100 } }).threshold({ limit: 70 }).isAnyOf({ matches: [ ThresholdRegion.ABOVE ] }).rewriteTo({ value: 100 });
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary:
This makes the common case (a single value and no options) more ergonomic.

Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3421
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Subscribers: vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3422
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Subscribers: vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3423
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3424
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3425
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3426
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Subscribers: vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3427
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3428
appsforartists added a commit that referenced this issue Oct 11, 2017
Summary: Part of #230

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, vietanh

Reviewed By: #material_motion, vietanh

Tags: #material_motion

Differential Revision: http://codereview.cc/D3429
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