This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @jsx: React.DOM */ | |
| var React = require('react'); | |
| var IfThingy = React.createClass({ | |
| render: function() { | |
| var ifThingy; | |
| if (this.props.someVar) { | |
| ifThingy = <h1>Some Var Is {this.props.someVar}</h1>; | |
| } | |
| else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function makeN(n, obj) { | |
| // gotta use .apply(null) because Array(n) makes a new empty array of size n and map behaves starngely | |
| // Array.apply(null, Array(n)) creates an array of size n with undefined as the value of every item | |
| // we can then call map on it to get back an array with n `obj`s. | |
| return Array.apply(null, Array(n)).map(function() { return obj; }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| React.renderComponent( | |
| <MomentPreviewList data={previewList}/>, | |
| document.getElementById('moment-live-feed') | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async.waterfall [ | |
| (cb) -> doStuff(cb) | |
| (result, cb) -> doOtherStuff(result, cb) | |
| (someOtherResult, cb) -> finally(someOtherResult, cb) | |
| ], (err, res) -> | |
| console.log 'res is', res | |
| # ᕕ( ᐛ )ᕗ WELP | |
| async.waterfall [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ticket = Backbone.Model.extend({ | |
| urlRoot: 'api/Ticket/' | |
| }); | |
| TicketView = Backbone.View.extend({ | |
| initialize: function(model) { | |
| this.model = model; | |
| this.listenTo(this.model, 'change', this.render.bind(this)); | |
| this.render() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <head> | |
| <title>Ordr: Rstaurant Mnu Systm</title> | |
| <script type="text/x-handlebars" data-template-name="tab"> | |
| <ul> | |
| {{#each tabItem in tabItems}} | |
| {{ partial "tabItem" }} | |
| {{else}} | |
| <li><h3>Click a food to add it</h3></li> | |
| {{/each}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Assume the error handling logic is pretty different at each async step, | |
| // and I have multiple different error conditions that require different | |
| // actions to handle them. | |
| // How can I do this with promises without passing some kind of additional | |
| // data to the error handler so it can know what logic to use? | |
| function someFattyAsyncThing(data, cb) { | |
| someAsyncOp(data, function (err, res) { | |
| if (err) { | |
| return cb(err); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base view class that all views extend | |
| # NOTE: This is from real production code, so it has some messiness for | |
| # dealing with real production issues. | |
| View = Backbone.View.extend | |
| initialize: (@model) -> | |
| @render | |
| super |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define( [ 'views/SearchView' ], function( SearchView ){ | |
| describe('SearchView', function() { | |
| var searchView, spy | |
| beforeEach(function() { | |
| setFixtures( $( "<input type='search' id='search'/>" ) ) | |
| searchView = new SearchView() | |
| searchView.render() | |
| spy = jasmine.createSpyObj( 'event', [ 'handler' ] ) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| destroy: function() { | |
| this.$el.remove() | |
| this.off() | |
| // destroy any children | |
| for (var selector in this.autoChildren) | |
| this.destroyChild(selector) | |
| this.autoChildren = null | |
| } |