-
Notifications
You must be signed in to change notification settings - Fork 20
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
Changes from 3 commits
e4f1480
61d0d02
d8d5649
b9d7dda
2c2a3cf
53ff202
90bf12d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Mixin from 'ember-metal/mixin'; | ||
import getOwner from 'ember-getowner-polyfill'; | ||
import computed from 'ember-computed'; | ||
|
||
export default Mixin.create({ | ||
_fastboot: computed(function() { | ||
let owner = getOwner(this); | ||
return owner.lookup('service:fastboot'); | ||
}), | ||
|
||
_isFastBoot: computed.readOnly('_fastboot.isFastBoot') | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,12 @@ import injectService from 'ember-service/inject'; | |
import { A } from 'ember-array/utils'; | ||
import { isEmpty } from 'ember-utils'; | ||
import { throttle } from 'ember-runloop'; | ||
import FastBootCompatMixin from '../mixins/fastboot-compat'; | ||
|
||
|
||
const { testing } = Ember; | ||
|
||
export default Service.extend(Evented, { | ||
export default Service.extend(Evented, FastBootCompatMixin, { | ||
scrollActivity: injectService('ember-user-activity@scroll-activity'), | ||
|
||
EVENT_THROTTLE: 100, | ||
|
@@ -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; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before push? Or on entering the function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before push seems fine, since the |
||
window.addEventListener(eventName, this._boundEventHandler, true); | ||
} | ||
|
||
|
@@ -83,6 +86,7 @@ export default Service.extend(Evented, { | |
if (eventName === 'scroll') { | ||
this.get('scrollActivity').off('scroll', this, this._handleScroll); | ||
} else { | ||
if (this.get('_isFastBoot')) { return; } | ||
window.removeEventListener(eventName, this._boundEventHandler, true); | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
import FastbootCompatMixin from 'ember-user-activity/mixins/fastboot-compat'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Unit | Mixin | fastboot compat'); | ||
|
||
// Replace this with your real tests. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test here that just registers a mock There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
test('it works', function(assert) { | ||
let FastbootCompatObject = Ember.Object.extend(FastbootCompatMixin); | ||
let subject = FastbootCompatObject.create(); | ||
assert.ok(subject); | ||
}); |
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.
Weird indenting here
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.
Correcting.