States in Ember.js without using routes?

I am trying to understand if the states in Ember.js are only intended / implied for determination in the route manager and whether routes are an integral part of Ember. Pretty much all the guides I saw seem to suggest that you want to precisely coordinate the states and routes.

I want to create states that do not depend on routes, but only on the state of the application. For example, in the mail client, I might have the state "userHasSpecifiedRecipient". Only if this state is true can I enable the form message box. But obviously I don't want the URL to be:

myEmailClient.com#composingMessage_userHasSpecifiedRecipient_userIs... etc.

Are there any examples of this?

Second question: can I mix states associated with routes and states that are not?

Finally: I saw some tips that recommend people use the Ember sproutcore-statechart addon if they want things like parallel states. It's true?

+8
routes statechart
source share
2 answers

There is an implementation in EmberJS, Ember.StateManager. StateManager uses Ember.State to represent states in the destination machine that have enter and exit functions, etc. See Class: Ember. StateManager .

In the example using the StateManager, Ember.View uses it to manage various view states. Another example is Ember-Data, which uses a state manager to track the various states that a record can have.

To make life easier and avoid template code, the latest version of EmberJS implements the Router implementation, which is still very important for working with updates once or twice a week. You can find the latest version of GitHub downloads .

Ember.Router is a subclass of Ember.StateManager responsible for detecting the state of an application based on a URL. The application Ember.Router instance detects the browser URL when the application loads and tries to match it with the specific state of the application. In addition, the router will update the URL to change the state of the application over time. ( JSDoc in source Ember )

In addition, since Ember.Router extends Ember.StateManager and Ember.Route extends Ember.State , they are interchangeable. In fact, in just one day, additional support was provided to support a mixture of states and routes, see Main State Support Within Routes .

+4
source share

You can change the implementation of the location of the routers to "none" to disable these features. other methods are hash or history (with current ember-latest.js on github).

https://github.com/joliss/ember.js/blob/50aff86ef5b6847108bc8c32364171815c230d36/packages/ember-application/lib/system/location.js

 App.Router = Ember.Router.extend({ location : Ember.Location.create({ implementation : 'none' }) }); 
+2
source share

All Articles