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

Building Event-Driven Javascript Applications

Building Event-Driven Javascript Applications

kbingman

May 22, 2015
Tweet

More Decks by kbingman

Other Decks in Technology

Transcript

  1. • Scales Better • Easy Decoupled • Encourages a Modular

    Architecture for Easy Reuse • Easy to Test
  2. ui data request — ui:needsData ui user action — ui:followAction

    ui request — ui:closeModal ui moment — ui:columnoptionsShown data — data:calculateResults
  3. #nodejs + #browserify + #npm is hands down the greatest

    tool chain front end developers have ever had. - Paolo Fragomeni (@hij1nx)
  4. "scripts": { "test": "…", "build:js": "browserify src.js > app.js", "watch:js":

    "watchify app.js -o app.js --debug", "start": "serve public & npm run watch:js" }
  5. it('should transfer a payload', function() { $(document).trigger('testEvent', { thisisfun: true

    }); expect(spy.args[0][1]).to.equal({ thisisfun: true }); });
  6. it('should transfer a payload', function() { $(document).trigger('testEvent', { thisisfun: true

    }); expect(spy.args[0][1]).to.deep.equal({ thisisfun: true }); });
  7. Store: A postbox Dispatcher: The postman, drops mail in the

    postboxes View (or Component): Box owner, checks the box for mail Action Creator: The post office, manages postmen
  8. search: function (query) { AppDispatcher.handleViewAction({ actionType: 'UPDATE_QUERY', query: query });

    SearchAPI.searchInstagram(query) .done(actionCreator.receiveInstagramData) .error(actionCreator.handleAPIError); },
  9. var ActionCreator = { addItem: function () { // We'll

    going to call dispatcher methods. AppDispatcher.addItem({…}); } };
  10. var AppStore = DeLorean.Flux.createStore({ list: [], actions: { // Remember

    the `dispatch('addItem')` 'addItem': 'addItemMethod' }, addItemMethod: function (data) { this.list.push('ITEM: ' + data.random); // You need to say your store is changed. this.emit('change'); } });
  11. Building Modular Applications Without a Framework https://medium.com/node-js-javascript/working-without- frameworks-part-1-b948f281f782 What is

    Flux https://medium.com/brigade-engineering/what-is-the-flux- application-architecture-b57ebca85b9e Boiling React Down to a Few Lines of jQuery http://hackflow.com/blog/2015/03/08/boiling-react-down-to- few-lines-in-jquery/ Event Driven Applications with Backbone https://code.mixpanel.com/2015/04/08/straightening-our- backbone-a-lesson-in-event-driven-ui-development/