-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiple beacons with the same name #458
Conversation
…when a single beacon is present
@mattmarcum could you please fix lint? This looks good to me, but I'd like @ef4 to chime in to confirm this is the right fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make ESLint happy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this seems good to me. Once Serge’s comments are addressed this is good to go.
…pose Adding a hasBeacon method to the -ea-motion service to guard against costly recalculations
pushed up lint fixes |
@mattmarcum this is now published to npm as |
I tried that npm package locally and can confirm the errors no longer flood the console. |
This addresses #225
First commit I added a failing test that just had a beacon and two animated-ifs. That test fails like the bug describes.
After diving into the code a bit I feel that this assertion was put here in error. As the added test shows, when multiple animated components are present the beacon will add itself to the -ea-motion service once per new animation.
This is because the beacons are listening to all animations. The original authors didn't cover the case when multiple animations would start in the same cycle, i.e. when more than one animated component gets rendered on the page.
I added a
hasBeacon
method so that the Beacon component can return early if it's already added itself to the service.The problem the original author tried to help with, warning when devs add two similar named beacons, is tough to crack with this implementation. I think its better to just fix this error and fore-go the warning.
One thing to note, the original error didn't really impede animations. Throwing an error would effective cause the
addBeacon
task to exit early and the sprite never got updated.