bloc referral

If you are interested in learning to code with a mentor, try bloc and get $100 off.

Tuesday, February 24, 2015

Components not Controllers in Ember

Months ago I blogged about my experience with randomly pairing with a healthy hacker,  yesterday I concluded another random pairing and with an associate,  @jgwhite. Jamie leads the Ember UK meetup and I was looking for some ember help with my current project.

I am looking to create a database for diverse speakers in tech to share with the steamrolers community.

My specific task was looking to create a save function in my controller so when ever some one creates a new speaker with my speaker form, the createRecord function would fire. Unfortunately that was not happening and actually just throwing an uncaught error.













I spent a good part of my Sunday searching through stackoverflow and forum questions trying to figure out why functions were not working.

After a bout 10minutes of explaining my issue with Jamie, He was able to identify that my problem was due to my save action being nested in a SpeakerController and the form was calling it from the higher application layer. But it wasn't enough, just to replace the save action in the ApplicationController,he recommend to go a step further and create a Component.









I now understand that despite the common comparisons, Ember is nothing like Rails other than the fact they both have opinions. The Controllers work in entirely different ways and come Ember 2.0 the use of Controllers will be removed. I am now able to use the newly created speaker-form component to call my speaker.save() function and even add an a validations like containsInvalidCharater.

Ember is definitely a moving ship, just like all other well maintained Front-End frameworks. The learning curve is high and constantly moving, but the reward with easy prototyping client side applications is well worth it. I am looking forward to using the foundation I am building with this app to create more things with Ember.

If you are new to learning Ember, I would love to pair with you or chat about your app, in effort to pay forward the help I got with mine.

No comments:

Post a Comment