Ember.js: prepare your code to migrate from ember 1.x to ember 2.0

My question is, can anyone please guide me on moving from a controller based app to a core component?

I am creating a map app for my dog ​​training club. We specialize in finding missing people. To organize our training, we need an application for drawing tracks and adding elements to them, etc.

I started an app using Ember-Cli and OpenLayers-3. The app works well, but I would like to move the code out of the controller based on a basic approach.

I would also like to use more routing at the moment, I only have one route and all user interactions are handled by actions.

I have set up a repository on github for those who would be kind enough to help me:

https://github.com/mylen/mantrailling

if you want to inspect the code and test your local application you will need to change the referent using the title motif in your nav to use http://demo.melard.fr

You can see the beta version of the website on this page:

http://recherche.utilitaire.melard.fr/beta/map

Thank you in advance,

+1


source to share


1 answer


First, we need to clarify the intended use of components, controllers, and routes in ember.js.

Components are similar to Views, but they are isolated and therefore used to create reusable pieces of code that render your models visually.

Controllers are mainly used to decorate your models, but they are also used to maintain application state.

Routes represent the current state of the application. They are responsible for loading models and initializing controllers.

To solve your first problem (controllers -> components), you only need to move all view related things, and only that, into components. Your code that will decorate your model, such as an active waypoint flag, remains in the controller. You only need to bind the data of your models / controllers to the components using data binding. ( http://guides.emberjs.com/v1.11.0/components/passing-properties-to-a-component )

Your second problem (using routes) is a little more difficult to solve I guess. First you need to find all the states your application has. After that, you should transfer your material loading and saving model to these routes.

Edit Some links describing the problem.

https://github.com/ef4/rfcs/blob/routeable-components/active/0000-routeable-components.md



https://www.youtube.com/watch?v=QgycDZjOnIg

Edit 2 Your question is strongly related to How to move ember from 1.x to 2.0

because the changes you mentioned will be accompanied by ember 2.0.

Here are some additional links that describe how best to prepare for this update.

https://gist.github.com/samselikoff/1d7300ce59d216fdaf97

https://speakerdeck.com/tomdale/ember-2-dot-0-in-practice

http://discuss.emberjs.com/t/what-is-a-good-way-to-do-this-in-ember-2-0-no-itemcontroller-no-arraycontroller/6649

You can find many resources if you are looking ember 2.0

.

Edit 3 Here's what I think is the most informative source for supporting new Ember releases: https://www.youtube.com/watch?v=wsydQzQF4Ww

+2


source







All Articles