Add modifier method
Closed this issue · 2 comments
bobisjan commented
What do you think about adding modifier
"shortcut" method?
Similar to Helper class and helper method, the modifier
method would be useful for common use cases.
Usage
// app/modifiers/scroll-top.js
import { modifier } from 'ember-oo-modifers';
export default modifier(function scrollTop(element, [scrollPosition]) {
element.scrollTop = scrollPosition;
});
Implementation
// addon/-private/modifier.js
import Modifier from './modifier-native';
export default function modifier(modifierFn) {
return class extends Modifier {
didReceiveArguments(positional, named) {
modifierFn(this.element, positional, named);
}
}
}
sukima commented
Sure, You up for a PR? If not it will take me some time, I'm kinda busy.
bobisjan commented
Yes, I will send one 🙌.