vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
208.01k stars 33.69k forks source link

Different syntax for multi argument filters #8335

Closed thekonz closed 6 years ago

thekonz commented 6 years ago

What problem does this feature solve?

Currently, you create multi argument filters by writing a function, that takes in the value from the template as its first argument.

That was very unintuitive for me and I think it would be a simpler and cleaner approach if we could just write functions that return functions. This would also allow for currying/method chaining.

This is just my opinion, please let me know how you would like it (or if this has been discussed already; I couldn't find that discussion).

What does the proposed API look like?

// current syntax
const format = (value, currency) =>
  new Intl.NumberFormat("de-DE", {
    style: "currency",
    currency
  }).format(value);

// new syntax
const format = currency => value =>
  new Intl.NumberFormat("de-DE", {
    style: "currency",
    currency
  }).format(value);
yyx990803 commented 6 years ago

Sorry but this is subjective at best... adding an alternative syntax creates extra API surface, learning cost, maintenance cost, documentation complexity... I don't think this is worth adding.