Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
emberjs
Search
mmr
February 20, 2014
1
220
emberjs
sarma ruby meetup, Feb 2014
mmr
February 20, 2014
Tweet
Share
More Decks by mmr
See All by mmr
rails decorators
mribica
0
73
make your own gem
mribica
0
100
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
431
66k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
A Tale of Four Properties
chriscoyier
160
23k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
61k
The World Runs on Bad Software
bkeepers
PRO
71
11k
Balancing Empowerment & Direction
lara
4
680
Mobile First: as difficult as doing things right
swwweet
224
10k
Context Engineering - Making Every Token Count
addyosmani
5
220
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Gamification - CAS2011
davidbonilla
81
5.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Transcript
Sarma Feb, 2014
• @mribica • https://github.com/mribica/twtr
Ember.js • client-side MVC framework for creating ambitious web applications
Tradicionalni web • req • full page response • req
• full page response
Ajax • req • full page response • ajax req
• partial response
Pjax/Turbolinks • req na server • full page response •
ajax req • page body response
SPA • req na server • full page response •
ajax req • response.json (client-side rendering)
Ember.js • url driven aplikacija • discourse • demo •
MVC
MVC • App.Router • Em.Route • DS.Model ili Em.Object •
ArrayController, ObjectController • Template • Em.View
Model # models/tweet.js.coffee App.Tweet = DS.Model.extend body: DS.attr(‘text’) favorite: DS.attr(‘boolean’)
createdAt: DS.attr(‘date’)
View (Template) # templates/tweet.handlebars <div class=”tweet”> <small> {{moment}} </small> <p>
{{body}} </p> </div>
View (Em.View) # views/tweet_view.js.coffee App.TweetView = Em.View.extend templateName: ‘tweet’ didInsertElement:
-> # neki kod koji se treba izvrsiti nakon # ubacivanja tweet-a u DOM
View (Em.View) # views/tweet_area_view.js.coffee App.TweetView = Em.TextArea.extend escape: -> #
logika kada se pritisne esc key @sendAction ‘cancel’
Controller # controllers/tweet_controller.js.coffee App.TweetController = Em.ObjectController moment:(-> moment(@get(‘createdAt’)).fromNow() ).property()
Controller # controllers/tweets_controller.js.coffee App.TweetsNewController = Em.ObjectController action: save: -> #
logika za spremanje tweeta
App.Router # router.js.coffee App.Router.map -> @resource ‘tweets’, -> @route ‘new’
Em.Route # tweets_route.js.coffee App.TweetsRoute = Em.Route.extend # model hook model:
-> @store.find(‘tweet’)
Em.Route # tweets_route.js.coffee App.TweetsNewRoute = Em.Route.extend # model hook model:
-> @store.createRecord ‘tweet’
Em.Route • beforeModel(params,) • model(params) • afterModel(params) • setupController(controller, model)
Demo