ef4/ember-elsewhere

to-elsewhere is not working from engine when from-elsewhere is in main application

Closed this issue · 3 comments

Hello

I have {{from-elsewhere name="main"}} in the main application application.hbs file and I am trying to do
{{to-elsewhere named="main" .... }} from route based engines template file and nothing is happening. Maybe I am doing something wrong

Thanks

ef4 commented

I think this is engines doing what they're designed to do. You can probably configure your app to share the "ember-elsewhere" service with the engine and then they will interoperate.

toovy commented

@ashvardanyan I tried the same and it basically works (latest ember and engine versions). As @ef4 said the only "tricky" thing you need to do is to share the service, for reference I've added a source code example:

// app/app.js
const App = Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver,
  engines: {
    yourEngineName: {
      dependencies: {
        services: [
          'ember-elsewhere'
        ]
      }
    }
  }
});
<!-- app/application.hbs -->
{{from-elsewhere name="toolbar"}}
// your-engine-name/addon/engine.js
const Eng = Engine.extend({
  modulePrefix,
  Resolver,
  dependencies: {
    services: ['ember-elsewhere']
  },
});
<!-- your-engine-name/addon/application.hbs -->
{{to-elsewhere named="toolbar" send=(component "some-toolbar-button")}}

Tested with an in-repo-engine.

ef4 commented

Thanks @toovy I added a link to your helpful example comment in the README.