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

Move to new ld client package, import package via ember-auto import #133

Merged
merged 8 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions addon/services/launch-darkly-client-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getOwner } from '@ember/application';
import { assert, warn } from '@ember/debug';
import { run } from '@ember/runloop';
import Evented from '@ember/object/evented';
import { initialize } from 'launchdarkly-js-client-sdk';

import RSVP from 'rsvp';

Expand Down Expand Up @@ -38,14 +39,6 @@ export default Service.extend(Evented, {
return RSVP.resolve();
}

if (!window.LDClient) {
warn('Launch Darkly JS client not found. Defaulting all feature flags to "false"', false, { id: 'ember-launch-darkly.client-not-found' });

this.set('_client', NullClient);
chrisvdp marked this conversation as resolved.
Show resolved Hide resolved

return RSVP.resolve();
}

return this._initialize(clientSideId, user, streaming);
},

Expand All @@ -69,7 +62,7 @@ export default Service.extend(Evented, {

_initialize(id, user, streamingOptions) {
return new RSVP.Promise((resolve, reject) => {
let client = window.LDClient.initialize(id, user);
let client = initialize(id, user);

client.on('ready', () => {
this.set('_client', client);
Expand Down
10 changes: 0 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ module.exports = {
included() {
this._super.included.apply(this, arguments);

this.import('vendor/ldclient.js');

if (this._shouldIncludePolyfill()) {
this.import('vendor/eventsource.js');
}
Expand All @@ -35,21 +33,13 @@ module.exports = {
treeForVendor(vendorTree) {
let trees = vendorTree ? [vendorTree] : [];

trees.push(this._launchDarklyTree());

if (this._shouldIncludePolyfill()) {
trees.push(this._eventSourceTree());
}

return new MergeTrees(trees);
},

_launchDarklyTree() {
return new Funnel(path.dirname(require.resolve('ldclient-js/dist/ldclient.js')), {
files: ['ldclient.js'],
});
},

_eventSourceTree() {
return new Funnel(path.dirname(require.resolve('event-source-polyfill/eventsource.js')), {
files: ['eventsource.js'],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
"test-node": "./node_modules/mocha/bin/mocha nodetests/**/*-test.js"
},
"dependencies": {
"ember-auto-import": "^1.6.0",
"ember-cli-babel": "^7.7.3",
"ember-test-waiters": "^1.1.1",
"event-source-polyfill": "^0.0.9",
"ldclient-js": "1.7.4"
"launchdarkly-js-client-sdk": "^2.18.0"
},
"devDependencies": {
"@ember/optional-features": "^0.7.0",
Expand Down
Loading