Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lightning Talk: Fluxo (básico) Ember 1.x.x

Duke
July 24, 2015

Lightning Talk: Fluxo (básico) Ember 1.x.x

Duke

July 24, 2015
Tweet

More Decks by Duke

Other Decks in Programming

Transcript

  1. model () { return this.get('store').findAll('structural-context'); } afterModel (transition) { let

    superResult = this._super(transition); return this.get('consumer').setup() .then(() => superResult); } Model Route
  2. setupController(controller, model) setupController(controller, model) { let query = { structuralItemId:

    model.get('structuralItemId') }; this.get('store').query('structural-widget', query).then((structuralWidgets) => { controller.set('structuralWidgets', structuralWidgets); }); this._super(controller, model); } Controller Route
  3. renderTemplate(controller, model) sidebar: 'default', renderTemplate (controller, model) { this.render('sidebar', {

    outlet: 'sidebar' }); this.render(`sidebar/${this.get('sidebar')}`, { outlet: 'sidebar-content', into: 'sidebar' }); this._super(controller, model); } Route View
  4. Template View didInsertElement () { this._super(); Ember.run.scheduleOnce('afterRender', this, () =>

    { window.componentHandler.upgradeAllRegistered(); }); } MyView = Ember.View.extend({ classNames: ['my-class', 'my-other-class'] }); <div id="ember1" class="ember-view my-class my-other-class"></div> didInsertElement() willClearRender() willDestroyElement() willInsertElement()
  5. Controller Template <div class="col-sm-3"> {{#if model.parent}} <h3>PAI:</h3> {{#linkTo "structural_contexts.structural_context" model.parent}}

    {{model.parent.name}} ({{model.parent.structuralItemType}}) {{/linkTo}} {{/if}} </div> <h2 class="col-sm-5 text-center">{{model.name}} ({{model}})</h2>
  6. Controller View didInsertElement: -> ... controller = @get('controller') rdpApi =

    controller.get('rdpApi') config = controller.get('config') controller.get('features').set('go_to_page', null) ... Ember.$('.container').click ()-> controller.get('features').send('close') ... reader.on "error", (status)-> controller.send('invalidateSession') if status is 403