简体   繁体   中英

View management with Ember.StateManager (and not Ember.Router)

I'd like to user Ember to create an 'informational sign' type of application; The data displayed will be updated on a regular basis, but there is no user input or interaction. The application is configured and initialized based on URL parameters provided by an administrator. The layout and content of the application will change depending on the data in the feed the application is monitoring.

Ember.Router seems like overkill for this task because I don't need/can't have URL-based routes mapped to application state. Ember.StateManager seems perfect because it allows me to programmatically transition between states depending only on conditions met within the logic of my application, ignoring the current URL. The deprecated Ember.ViewState seems like it was the way to manage views when using Ember.StateManger.

What is the current best practice for managing views in the DOM with Ember.StateManger?

Is there a way to do what I'm describing with Ember.Router instead?

Thanks, Aaron

After reading your primary explanation, I feel that you dont need any states at the moment. You need diferent application stated defined when application needs different behaviour in those states. Looks like your application behaviour is not changing but just view.

So you can just use some handlebars condition helpers to make this work along with some derived attribute in your controller indicating whether there is any current advisory.

{{#view App.myView}}
  {{#if hasAdvisory}}
    <div class="col-2">
      <div class="col1">
        {{#each bus}}
          //bus details
        {{/each}}
      </div>
      <div class="col2">
        //advisory details
      </div>
    </div>
  {{else}}
    <div class="col-1">
      <div class="col">
        {{#each bus}}
          //bus details
        {{/each}}
      </div>
    </div>
  {{/if}}
{{/view}}

Please explain more like if you just need this or do you plan any different application behaviours when you have advisory and when you dont have.

In general, the same techniques used to manage views and controllers in Ember.Router -based apps can be used with Ember.StateManager . Specifically, using outlets with Em.Controller#connectController is an excellent way to switch views that is independent of state management.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM