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

Multiple events triggered if instantiated multiple times #38

Open
iJungleboy opened this issue Nov 7, 2016 · 3 comments
Open

Multiple events triggered if instantiated multiple times #38

iJungleboy opened this issue Nov 7, 2016 · 3 comments

Comments

@iJungleboy
Copy link

There are cases where multiple things on the screen may init a new Shake(). For example, if a CMS has various components which the editor adds, and more than one of them want to enable shake detection.

At the moment, this causes the shake-event to trigger for each initialized Shake(), so code outside "my" scope could cause the shake-event to occur multiple times.

I believe Shake() should somehow either

  1. check if it's already running, and return the running instance
  2. OR manage a list of registered Shakes and remove one
  3. OR change the concept (or offer the alternative) to use a callback - there seems to be a fork which does this; shake could just offer both: JonWallsten@3989b49
@alexgibson
Copy link
Owner

How many pieces of code do you have running on one page that all need to respond to a shake event in different ways? What are they all doing? I'm curious if this is a common need.

When I get round to it, changing this plugin to use a callback is something I plan on doing if that helps.

@iJungleboy
Copy link
Author

So the scenario I'm talking about is a web-platform scenario which may have components from multiple vendors - let's say a CMS component which uses shake to show buttons (http://2sxc.org/en/blog/post/introducing-shake-mobile-content-editing-just-turned-sexy) and another one which maybe will use shake do something with an image gallery. Now both vendors don't know about each other, but when the CMS-owner adds both components, both would start a Shake() and this would double-trigger the event.

@alexgibson
Copy link
Owner

This sounds like a larger architecture issue with your CMS, but I'm happy to move to a callback API.

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

2 participants