-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
single behavior for accessing any instance property #3569
Comments
I'm 👎 on this. I think the use of |
in defense of my point i would like to offer this example:
maybe |
The reason why var MyThing = Mn.Thing.extend({
foo: 'bar',
setFoo(val) {
this.foo =val;
},
doFoo() {
this.gizmo.do(this.getOption('foo'));
}
});
var myThing = new MyThing({ foo: 'baz' });
myThing.doFoo(); // did with 'baz'
myThing.setFoo('bazinga');
myThing.doFoo(); // still done with 'baz' because nothing can override the option.
myThing.foo = 'still no change';
myThing.doFoo(); :-/ |
hm... and they both can be smart, of course |
I would lean towards removing |
utils/smart-get-property.js
utils/smart-get-option.js
utils/is-know-ctor.js
:) |
I'm strongly against adding this to Mn core. It can be provided as a 3rd party plugin for anyone interested in incorporating these features. If the community and/or @marionettejs/marionette-core feels strongly otherwise, we can reopen for further discussion. |
Sometimes i just do not remember can i define a property as function or not.
that`s because of different behavior in different cases.
sometimes its possible, sometimes its not.
i want to offer little improvement for resolving this "issue"
getOption
always returns raw valueso, if i have an option as function i have to wrap it by function invoker if i need the result of that function.
_.result
do not accepts arguments, only default value for empty result._.result
do not handle constructors, and i think its possible to handle it, atleast for known constructorsso, here is my improvement
i offer to extend
getOption
and if an user needs some smart behavior he can pass force attributethis will return value or class
and by default
getOption
will work as todaythis can help to pass any property as value, definition or a function
and the behavior will be same everywhere.
The text was updated successfully, but these errors were encountered: