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
    Controller
    Route
    Template
    View

    View full-size slide

  2. Model Route
    model(p, t)
    beforeModel(transition)
    afterModel(resolvedModel, transition)
    Promise
    Promise
    Promise

    View full-size slide

  3. model () {
    return this.get('store').findAll('structural-context');
    }
    afterModel (transition) {
    let superResult = this._super(transition);
    return this.get('consumer').setup()
    .then(() => superResult);
    }
    Model Route

    View full-size slide

  4. 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

    View full-size slide

  5. 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

    View full-size slide

  6. Template
    View
    didInsertElement () {
    this._super();
    Ember.run.scheduleOnce('afterRender', this, () => {
    window.componentHandler.upgradeAllRegistered();
    });
    }
    MyView = Ember.View.extend({
    classNames: ['my-class', 'my-other-class']
    });

    didInsertElement()
    willClearRender()
    willDestroyElement()
    willInsertElement()

    View full-size slide

  7. Controller
    Template

    {{#if model.parent}}
    PAI:
    {{#linkTo "structural_contexts.structural_context" model.parent}}
    {{model.parent.name}} ({{model.parent.structuralItemType}})
    {{/linkTo}}
    {{/if}}

    {{model.name}} ({{model}})

    View full-size slide

  8. 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

    View full-size slide