WarsawJS Presentation: Template

We talk about JavaScript. Each month in Warsaw, Poland.

Speaker

Krzysztof BiaƂek

"Ember 2.0 - whats new and how to upgrade?"

2015-10-21

@drwrum

Me

Why we like Ember

But is it really true?

What was wrong?

The Ember Project

Starting from version 2.0 coordinated relase of Ember with releases of the main ecosystem tools maintained by the core team. This will allow painless update of related tools in the project.

1.13 is the new 2.0...




almost

The new and shiny rendering engine.



                { enabled: true, name: "Tom Dale",
                  details: "A True Scotsman" }
            
                <div class="item">
                  {{#if enabled}}
                    <p>It's Enabled</p>
                  {{/if}}
                  <p>{{name}}</p>
                  <p class="popover">{{details}}</p>
                </div>
            

Changes and deprecations

Changes and deprecations

New syntax for bind-attr

                <div {{bind-attr class="isActiveUser"}}></div>

                // Need to be changed to:

                <div class={{if isActiveUser 'is-active-user'}}></div>
            

Changes and deprecations

One-way values by default

                {{!-- title is a mutable two-way binding --}}
                {{my-component title=model.name}}

                {{!-- title is just an (immutable) value --}}
                <my-component title={{model.name}} />
            

New stuff => helpers and components

New stuff => component attrs property

New stuff => each-in helper

                let items = {
                  "Item 1": 1234,
                  "Item 2": 3456
                };

                {{#each-in items as |key value|}}
                  <p>{{key}}: {{value}}</p>
                {{/each-in}}
            

New stuff => get helper

                let items = {
                  "Item 1": 1234,
                  "Item 2": 3456
                };

                {{get items 'Item 1'}}
                // or
                {{get items somePathReturningKey}}
            

New stuff => mut helper

Way to modify parent value with one way binding
                // before 1.13 
                {{my-counter count=activatedCount}}

                // but we still want to update parent value

                <my-counter count={{mut activatedCount}} />
            

One more thing...

Drop support for IE8!!!

How to upgrade

How to upgrade - tools

What about Ember Data?

Changes to find

What about Ember Data?

New methods for quering server/storage

Async from server/store Sync from store Query server
Single Record findRecord(type,id) peekRecord(type, id) queryRecord(type, {query})
All Records findAll(type) peekAll(type) query(type, {query})*

Where to go next?

Happy updating!

Fork me on Github

Fullscreen