Slide 1

Slide 1 text

ember:&when&the&lights&go&on @grandazz github.com/achambers

Slide 2

Slide 2 text

developing*since*2000 Javascript Ruby Java$and$Lotus$Notes

Slide 3

Slide 3 text

github.com/ember.cli/ember.cli.deploy

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Wenguins

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

this%is%not an#ember#is#be(er#than#everything#else presenta(on

Slide 9

Slide 9 text

browser'dev'boiled'down (shamelessley)borrowed)from)@ryanflorence) interac(ng*with*data*stores rendering'data'to'ui responding*to*user*interac/on router&&&urls project(stuff:(file(organisa3on,(build(tools(etc

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

the$wenguins'$journey$with ember

Slide 12

Slide 12 text

lightbulb!moments

Slide 13

Slide 13 text

we#didn't#just#jump#in

Slide 14

Slide 14 text

we#needed#to validate the$switch

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Service'Status

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

// app/assets/javascripts/application.js function bindViewMoreDetailsLinks() { $('.more-details').hide(); $('.view-more').click(function(e) { e.preventDefault(); var $viewMoreLink = $(this); var $moreDetails = $viewMoreLink.parents('.issue').find('.more-details'); if ($moreDetails.is(':visible')) { $moreDetails.hide(); $viewMoreLink.text('More details'); } else { $moreDetails.show(); $viewMoreLink.text('Less details'); } $viewMoreLink.toggleClass('opened'); }); }

Slide 20

Slide 20 text

// app/assets/javascripts/application.js function toggleElementsForEditors() { $.ajax({ url: '/sessions/current', dataType: 'json', success: function(data) { var loggedInStatus = data.logged_in; toggleNewIssueLink(loggedInStatus); toggleHeader(loggedInStatus); toggleAdditionalLinks(loggedInStatus); toggleSidebar(loggedInStatus); toggleFooter(loggedInStatus); toggleEditIssueLinks(loggedInStatus); toggleResolveIssueLinks(loggedInStatus); } }); }

Slide 21

Slide 21 text

// app/assets/javascripts/application.js function toggleHeader(loggedInStatus) { $('#skycom-masthead-wrapper').toggleClass('hidden', loggedInStatus); } function toggleAdditionalLinks(loggedInStatus) { $('.additional-links').toggleClass('hidden', loggedInStatus); } function toggleSidebar(loggedInStatus) { $('.sidebar').toggleClass('hidden', loggedInStatus); } function toggleFooter(loggedInStatus) { $('#skycom-footer-wrapper').toggleClass('hidden', loggedInStatus); } function toggleEditIssueLinks(loggedInStatus) { $('.btn.edit-issue').toggleClass('hidden', !loggedInStatus); } function toggleResolveIssueLinks(loggedInStatus) { $('.btn.resolve-issue').toggleClass('hidden', !loggedInStatus); }

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

data$based$ui$manipula.on

Slide 24

Slide 24 text

// app/views/issues/index.html.haml function microfilterCheck() { var deferred = $.Deferred(); $.getJSON('/sessions/current', function(json) { if (json.logged_in) { deferred.resolve() } else { Hub.runMicrofilterTest() .done(function() { deferred.reject(); }) .fail(function() { deferred.resolve(); }); } }); return deferred; }

Slide 25

Slide 25 text

// app/views/issues/index.html.haml function restrictionCheck() { var deferred = $.Deferred(); $.getJSON('/customers/current', function(json) { if (json.customer.has_debt_restriction) { deferred.reject('debt'); } else if (json.customer.has_high_spend_restriction) { deferred.reject('spend'); } else { deferred.resolve(); } }, function() { deferred.resolve(); }); return deferred; }

Slide 26

Slide 26 text

// app/views/issues/index.html.haml $(function() { var microfilterDeferred = microfilterCheck() var restrictionDeferred = restrictionCheck() $.when(microfilterDeferred, restrictionDeferred).always(function() { var args = Array.prototype.slice.call(arguments); if (restrictionDeferred.state() == 'rejected') { if (args.indexOf('spend') !== -1) { $('.high-spend-restriction-alert').removeClass('hidden'); } else if (args.indexOf('debt') !== -1) { $('.debt-restriction-alert').removeClass('hidden'); } } else if (microfilterDeferred.state() == 'rejected') { $('.microfilter-alert').removeClass('hidden'); } showIssues(); }); });

Slide 27

Slide 27 text

then%the%very%next%commit...

Slide 28

Slide 28 text

// app/views/issues/index.html.haml $(function() { IssuesIndexController.init(); });

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

controllers

Slide 31

Slide 31 text

// app/assets/javasctipts/User.js var User = { isAnEditor: function() { var deferred = $.Deferred(); $.ajax({ dataType: 'json', url: '/sessions/current', success: function(data) { deferred.resolve(data.logged_in); }, error: function() { deferred.reject(); } }); return deferred.promise(); } }

Slide 32

Slide 32 text

// app/assets/javascripts/Diagnostics.js var Diagnostics = { run: function() { //run some diagnostics goodness } } // app/assets/javascripts/CBS.js var CBS = { run: function() { //run some monstrosity of a service, //return a massive payload we don't need //and take forever to do so } }

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

models & interac(ng*with*data*stores

Slide 35

Slide 35 text

// app/assets/javascripts/views/IssueView.js (function() { window.IssuesView = { render: function() { this._showIssues(); this._toggleStatusMessage(); } // ...snip... }; })(); // app/assets/javascripts/views/DebtAlertView.js (function() { window.DebtAlertView = { render: function() { this._showAlert(); this._hideProducts(); this._hideSidebar(); this._informScreenReader(); } // ...snip... }; })();

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

views

Slide 38

Slide 38 text

{!-- app/assets/javascripts/templates/outages.hbs --}} {{#each outages}}

{{description}}

Date issue was reported {{startedOn}}

{{/each}}

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

templa'ng

Slide 41

Slide 41 text

we#started#to#build#our#own#framework

Slide 42

Slide 42 text

we#started#to#build#our#own#framework BADLY

Slide 43

Slide 43 text

Use$a$framework,$or$don't.$Either$ way,$you$will. —"Someone"Awesome

Slide 44

Slide 44 text

conven&on'over'configura&on this.resource('posts', { path: '/posts' }) PostsRoute PostsController PostsView posts.hbs

Slide 45

Slide 45 text

no#more#globals var Diagnostics = { run: function() { // do stuff } }; window.IssuesIndexController = { init: function() { // do stuff; } };

Slide 46

Slide 46 text

no#more#globals#,>#es2015#modules // app/controllers/go-issues.js export default Em.ArrayController.extend({ status: function() { //do stuff }.property('hasProblem') }); // app/models/outage.js export default DS.Model.extend({ //attributes here }); // app/components/ss-accordion.js export default Em.Component.extend({ collapsed: false, //other properties here });

Slide 47

Slide 47 text

data$binding // models/tv_issue.js export default DS.Model.extend( name: DS.attr('string') ); // controllers/tv_issues.js export default Em.ArrayController.extend({ });
    <#each>
  • {{name}}

Slide 48

Slide 48 text

lightbulb(moments didn't&stop there

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

leave%your%assump-ons at#the#door

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

don't&fight&the&framework

Slide 60

Slide 60 text

If#something#feels#harder#than#it# should#be,#it#probably#is.#You're# probably#doing#it#wrong. —"Someone"Awesome

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

ui#error#logging

Slide 64

Slide 64 text

ui#error#logging Ember.onerror = handleError; Ember.RSVP.on('error', handleError); function handleError(error) { Em.$.ajax('/error', { type: 'POST', data: { stack: error.stack } }); }

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

separa&on)of ui#and#api

Slide 68

Slide 68 text

clearer&separa)on&between&data and$user$interac,on

Slide 69

Slide 69 text

think&not&of&your&api&in&terms&of&ui& interac2ons,&but&in&terms&of&data& and&rela2onships

Slide 70

Slide 70 text

your%app%is%a client'of'your'api

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

build&tools

Slide 74

Slide 74 text

build&tools lightening(fast(deployments

Slide 75

Slide 75 text

build&tools lightening(fast(deployments pact%file%tes*ng

Slide 76

Slide 76 text

Come%and%chat%to%me

Slide 77

Slide 77 text

Come%and%chat%to%me at#the#bar tonight

Slide 78

Slide 78 text

Come%and%chat%to%me Thursday)9th)April 2"Wellington"Place

Slide 79

Slide 79 text

Aaron&Chambers @grandazz github.com/achambers

Slide 80

Slide 80 text

any$ques)ons? @grandazz github.com/achambers

Slide 81

Slide 81 text

thanks'for'having'me