Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>What mechanism should I use when communicating between views that are not in a child/parent hierarchy?</p> </blockquote> <p>In a typical ember application this communication should happen between controllers. Otherwise "Poor Option 2" is on the right track:</p> <blockquote> <p>Communication could be handled by a controller (and possibly even a model) that would hold properties that the toolbar sets and the "listening" view reacts to and resets the value of. </p> </blockquote> <p>Consider using two controllers. Toolbar actions will target the <code>ToolbarController</code>, which is responsible for maintaining the toolbar's state and for changing main in response to user action. <code>ToolbarController</code> should declare a dependency on <code>MainController</code> via the <code>needs</code> property. For example:</p> <pre><code>App.ToolbarController = Ember.Controller.extend({ needs: ['main'], buttonOneGotAllPressed: function() { main = this.get('controllers.main'); main.turnOffAnOption(); main.makeSomeOtherChange(); } }); </code></pre> <p>Now <code>MainController</code> can be focused on the state of MainView. It should not be aware of <code>ToolbarController</code> or it's buttons.</p> <blockquote> <p>This sounds like abuse of the controller and model purposes and like a pretty poor event listener setup.</p> </blockquote> <p>Agreed it would likely be an abuse of model purposes but it is exactly what controllers are for. </p> <p>This is definitely not an event-listener setup, but that does not seem a good fit in your case. The toolbar you describe seems to exist only to interact with the main view, so it makes sense to have a toolbar controller that depends on main and interacts with it directly. </p> <p>If the components are truly decoupled then an observer (Pub/Sub) pattern might be more appropriate. See <a href="https://stackoverflow.com/questions/14458287/how-to-fire-an-event-to-ember-from-another-framework/14508316#14508316">How to fire an event to Ember from another framework</a> if that's of interest.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload