Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Simplify the API? #26

Open
dandv opened this issue Apr 17, 2015 · 8 comments
Open

Simplify the API? #26

dandv opened this issue Apr 17, 2015 · 8 comments

Comments

@dandv
Copy link
Contributor

dandv commented Apr 17, 2015

The current flow for detecting a shake looks more complicated than it needs to be:

var myShakeEvent = new Shake({ ... senstivity options ... });
window.addEventListener('shake', shakeEventDidOccur, false);
window.removeEventListener('shake', shakeEventDidOccur, false);
myShakeEvent.stop();

@leecrossley's cordova-plugin-shake-detection has a minimally simple API:

shake.startWatch(shakeEventDidOccur, /* ... sensitivity options ... */);
shake.stopWatch();

Could the API be simplified?

@alexgibson
Copy link
Owner

This is indeed on my road-map. I plan to remove the shake custom event, and simply allow folks to pass their callbacks on instantiation.

@dandv
Copy link
Contributor Author

dandv commented Apr 17, 2015

Great to hear!

I could imagine a use case for having more Shake instances instead of a singleton (e.g. supporting light shakes vs. heavy shakes), but the shake event doesn't receive any parameters, so it couldn't distinguish how it was called anyway.

@alexgibson
Copy link
Owner

Will the request full screen from the API work with the shake event ?

This isn't really related to this issue. Not quite sure I understand your question, but you can execute any code you want when the event occurs. Please see the readme for how to use the plugin.

@alexgibson
Copy link
Owner

I tried the proximity api to execute fullscreen , it did not happen

What does that have to do with this plugin?

@alexgibson
Copy link
Owner

As far as I understand that's a limitation of the full screen API, not this plugin. Shake is a custom event, so not necessarily the same as a native click.

Regardless, this has nothing to do with this issue. Please open a new issue if you would like to discuss this further.

@dandv
Copy link
Contributor Author

dandv commented Jun 11, 2015

I'm sorry @abkhan25 but the comments about full-screen and whatnot are off-topic here.

@alexgibson: feel free to delete the clutter, including this comment of mine.

@JonWallsten
Copy link

I can here to propose a callback instead of custom event as you mentioned in second comment. I need to play a sound when user shakes, but it's not possible with a custom event. It requires a user interaction. Which I guess device motion is. So a callback should fix that.

@avrebarra
Copy link

up up, this is important issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants