angular-hammer icon indicating copy to clipboard operation
angular-hammer copied to clipboard

Option to disable callable return values

Open nateabele opened this issue 10 years ago • 4 comments

First of all, thanks for porting this library to Hammer v2.

So, this guy has been giving me no end of trouble.

I write my JS to be as composable as possible, which means two things: (1) the internal logic doesn't know anything about the UI, (2) most things return functions.

Even accounting for this, whenever you integrate a 3rd-party lib you have no control over, you need to make sure you wrap all your calls in something that'll nuke the return value. I get why the behavior is the way it is, but it'd sure be nice to have a module-level setting to disable it.

Lemme know if this seems reasonable and if you'd like a PR.

nateabele avatar Jan 26 '15 14:01 nateabele

So I might need more clarification, but this seems like you want a flag that I can use to disable the execution of the function parsed from the expression? The easiest way to integrate this (and it is very easy) would be with an extension to the recognizer option, we could call it preventExecution or something like that. Would that work for you?

I don't know that I want a module-level flag given that I could want it in some cases but not in others (I don't really have a use case in mind, but it's a situation that could theoretically exist).

RyanMullins avatar Jan 26 '15 15:01 RyanMullins

The easiest way to integrate this (and it is very easy) would be with an extension to the recognizer option, we could call it preventExecution or something like that. Would that work for you?

Strictly speaking, yes, but the ultimate goal is to specify that in one place. (Or are you suggesting that's possible by adding recognizer options?).

I don't know that I want a module-level flag given that I could want it in some cases but not in others (I don't really have a use case in mind, but it's a situation that could theoretically exist).

Maybe a module-level configuration for default recognizer/manager options would be more generically useful? In my case, I know that I never want return values to be directly acted upon by handlers, so being able to specify that in one place would be great.

Hopefully that makes sense and I'm understanding you correctly.

nateabele avatar Jan 26 '15 15:01 nateabele

Hmm... I forgot about the config settings in Angular (rarely use them myself). Let me think about that approach. I am in the process of revamping the way I define recognizer and manager options for v2.2 already, so this could just be added to that work.

RyanMullins avatar Jan 26 '15 16:01 RyanMullins

Nice, thanks man.

nateabele avatar Jan 26 '15 19:01 nateabele