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

fastboot compatibility #67

Merged
merged 7 commits into from
Oct 12, 2016
Merged

fastboot compatibility #67

merged 7 commits into from
Oct 12, 2016

Conversation

tylerturdenpants
Copy link
Collaborator

No description provided.

includes getOwner polypill for older versions of ember and adds mixin
to insert fastboot services
import computed from 'ember-computed';

export default Mixin.create({
_fastboot: computed(function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indenting here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting.

@@ -38,6 +40,7 @@ export default Service.extend(Evented, {
this.get('scrollActivity').on('scroll', this, this._handleScroll);
} else if (this._eventsListened.indexOf(eventName) === -1) {
this._eventsListened.push(eventName);
if (this.get('_isFastBoot')) { return; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably move this check higher...I'm not sure it makes sense for us to mark that an event is being listened to (via push) if we're not actually going to call addEventListener

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before push? Or on entering the function?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before push seems fine, since the scrollActivity service has its own code to handle fastboot compat


module('Unit | Mixin | fastboot compat');

// Replace this with your real tests.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test here that just registers a mock fastboot service, and another one that doesn't (and confirms that isFastBoot is false as a result)>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wanted to ask this question originally. But yes I will certainly do that. Thanks for the review!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fastboot service is only available when it is injected by the fastboot server, so this.get('this.get('_isFastBoot') will be undefined, ( the computed property _fastboot will return undefined) in the browser context. To verify the existence of the fastboot service a test would need to be written that gets run as a result of being contained within a fastboot server instance, like using https://github.com/kaliber5/ember-fastboot-addon-tests .

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the real fastboot service, you can simply inject a mock service called fastboot that has an _isFastBoot property. For the non-FastBoot test, you can literally just do nothing and check that the CP evaluates to false (undefined) as expected

@elwayman02
Copy link
Owner

A few minor comments, but I really like where this ended up! We should be good to merge once the above is addressed.

@elwayman02
Copy link
Owner

Awesome, this looks great! Thanks @tylerturdenpants!

@elwayman02 elwayman02 merged commit f7436bb into elwayman02:master Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants