Skip to content
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

Merged
merged 2 commits into from
Apr 22, 2022

Conversation

mattmarcum
Copy link
Contributor

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.

@SergeAstapov SergeAstapov requested a review from ef4 April 22, 2022 16:30
@SergeAstapov
Copy link
Collaborator

@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.

Copy link
Collaborator

@SergeAstapov SergeAstapov left a 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

Copy link
Contributor

@ef4 ef4 left a 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
@mattmarcum
Copy link
Contributor Author

pushed up lint fixes

@mattmarcum mattmarcum requested a review from SergeAstapov April 22, 2022 17:48
@SergeAstapov SergeAstapov changed the title Multiple Beacon bugs Multiple Beacon bugs Apr 22, 2022
@SergeAstapov SergeAstapov changed the title Multiple Beacon bugs Allow multiple beacons with the same name Apr 22, 2022
@SergeAstapov SergeAstapov merged commit 6497bef into ember-animation:master Apr 22, 2022
@SergeAstapov
Copy link
Collaborator

SergeAstapov commented Apr 22, 2022

@mattmarcum this is now published to npm as ember-animated@1.0.2-unstable.6497bef could you please give it a try?

@mattmarcum mattmarcum deleted the beacon-bug branch April 22, 2022 19:27
@mattmarcum
Copy link
Contributor Author

mattmarcum commented Apr 22, 2022

I tried that npm package locally and can confirm the errors no longer flood the console.

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

Successfully merging this pull request may close these issues.

"Error: There is more than one beacon named <beaconname>" when there isn't
3 participants