





























– By Peter Wagenet
Today at Ember Camp, we announced the release of Ember.js 1.0 RC1.
This release is all about fixing bugs from the pre4 release, and
gets us that much closer to a final 1.0 release. Between this release
and the 1.0 final, we will mostly be focusing on stability and documentation.
If you discover any blocking bugs or undocumented areas, please file tickets at the emberjs/ember.js repo on GitHub and consider helping out.
You can now transition to a new route without creating an entry in the history:
// instead of this, which creates a history entry
router.transitionTo('index');
// do this
router.replaceWith('index');
In the redirect hook, you can use replaceWith and Ember won't create
a history entry.
In a controller, you can use replaceRoute (instead of transitionToRoute)
to do the same thing.
If you want every item in a {{#each}} to be wrapped in an ObjectController,
you can do so:
{{#each posts itemController="post"}}
{{!-- `this` in here is each post wrapped in an App.PostController --}}
{{/each}}
Internally, Ember uses a "container" to instantiate your controllers and other objects.
As of Ember 1.0 RC1, you can use App.register to override the default lookup
for controllers and other objects. For example:
App.register('controller:post', Ember.ObjectController.extend());
In general, you should use the default naming conventions, which Ember will use to find objects, but you can use this API for advanced usages.
Similarly, you can use App.inject to tell Ember to automatically inject
objects into other Ember objects.
App.register('network:main', App.NetworkAdapter);
App.inject('controller', 'network', 'network:main');
This will create a single instance of App.NetworkAdapter and give it to every
controller created over the course of building your application. Internally,
Ember Data uses this API to give every controller the application's store:
Currently, many people are using the undocumented and private enter and
exit hooks to run code whenever Ember activates a route handler or
deactivates it.
As of Ember 1.0 RC1, there are public hooks: activate and deactivate. Note
that the activate hook will run only when a route handler is activated for
the first time. If a route handler's context changes, the setupController
hook will run again, but not the activate hook.
If you are trying to run integration tests with Ember, you might have noticed that there is no good way to reset all of an application's state.
No more!
As of Ember 1.0 RC1, you can call App.reset() to destroy all objects created
for the application, and bring the application back to /.
Since .pre4, we've added these features:
router.replaceWith{{action}} and {{linkTo}} to
differentiate between static String parameters and properties on the current
contextitemController, which allows a {{#each}} to wrap each iterated element
in a controller that can be used to store transient stateintersection to EnumerableUtilsApp.register and App.inject to control the default application's
dependency injection container{{unbound helper}} where helper is a custom helper
registered via Ember.Handlebars.registerBoundHelperEmber.debug to print debug-level warnings and use it to print the
current version of Ember and its dependencies on boot{{render}} does not
update the rendered templateactivate and deactivate hooks in the router. If you were
using the private enter and exit methods, please switch!Application#reset to help with integration testsYou can see the full changelog at the official CHANGELOG.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。