Makes it easier to embed your Ember application in another (non-Ember) app.
This addon gives you more control over how and when your Ember app will boot and also allows to add/override some configuration, so that the Ember app can boot with some context-dependent config.
We found it especially useful, for example, when migrating an existing app to Ember part by part.
ember install ember-cli-embedded
This plugin is opt-in; by default, it does nothing to your app unless you configure it.
In your config/environment.js
, add the following config to the ENV
:
modulePrefix: 'my-app' // name of your application
exportApplicationGlobal: true, // exposes your application in production builds
...
embedded: {
delegateStart: true,
config: { // `config` is optional
// Default values for the config passed at boot
}
}
For compatibility reasons, as long as the value for
embedded
is truthy, your app will hold until you start it. This behaviour will be removed in future versions. Please stick to the config format above.
This addon relies on ember-export-application-global
to expose a global variable. By default, it exposes your app under
its capitalized name, eg. MyApp
. See its documentation for
more configuration information.
In your JS code, just execute MyApp.start(/* optionalConfig */)
to resume
the boot of your application. As per the example, it takes an optional
configuration as its first argument.
Remeber: Your app will not start unless you call the MyApp.start(/* optionalConfig */)
method.
You can inject the embedded
service to access the config:
EmberObject.extend({
embedded: service(),
logSomeConfigKey() {
const value = this.get('embedded.myKey');
console.log(value);
}
});
Note: It is sometimes more convenient to access the data from the container directly:
// Returns the raw config
let embeddedConfig = Ember.getOwner(this).lookup('config:embedded');
The passed configuration will be merged in your APP
configuration key,
which is very useful, for instance, if you want to change the rootElement
of your application and other context-sensitive values.
Make sure that, in your config/environment.js
, you disable the addon for the
test
environment, with the following:
ENV.embedded.delegateStart = false;
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember serve
- Visit the dummy application at http://localhost:4200.
For more information on using ember-cli, visit http://www.ember-cli.com/.
This project is licensed under the MIT License.