This file contains 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
Backbone.Layout = Backbone.View.extend({ | |
initialize: function() { | |
// a map of selector -> view references | |
this.view_references = {}; | |
// the promises for the data | |
// required before rendering the view | |
this.promises = this.data? _.map(this.data(), function(model) { |
This file contains 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
require [ | |
'zepto', | |
'osc/client', | |
'gui/range' | |
], ($, OscClient, RangeView) -> | |
osc_client = new OscClient | |
bar_view = new RangeView | |
model: osc_client |
This file contains 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
# event emitter is an object which is | |
# responsible for triggering events, and binding | |
# functions to those events. | |
class EventEmitter | |
# events map event names | |
# to functions which are bound | |
# to that event. calling model.on evt, fn | |
# will add that function to the events hash. | |
events: null |
This file contains 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([ | |
'backbone' | |
], function(Backbone) { | |
return Backbone.Collection.extend({ | |
url: '/boops' | |
}, { | |
byUserId: function(user_id) { |
This file contains 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 [ | |
'backbone', | |
'resources/user' | |
], (Backbone, User) -> | |
class extends Backbone.Model | |
idAttribute: '_id' | |
urlRoot: '/sessions' | |
defaults: |
This file contains 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
Backbone.Layout = Backbone.View.extend({ | |
initialize: function() { | |
this.viewReferences = {}; | |
Backbone.View.prototype.initialize.apply(this, arguments); | |
}, | |
setView: function(selector, view) { | |
var $foundViewNode = $(selector, this.$el), | |
previousView = this.viewReferences[selector]; |
This file contains 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
Backbone.CollectionLayout = Backbone.Layout.extend({ | |
initialize: function() { | |
Backbone.Layout.prototype.initialize.apply(this, arguments); | |
this.listenTo(this.collection, 'add', _.bind(this.modelAdded, this)); | |
}, | |
ItemView: Backbone.Layout, | |
modelAdded: function(model) { |
This file contains 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
### | |
a small connect middleware proxy for cross domain ajax | |
@path first match group will be forwarded | |
@host the host you want to proxy | |
connect_server.use proxy '^(/.+)', 'api.twitter.com' | |
connect_server.use proxy '^/gh(/.+)', 'api.github.com' | |
### |
This file contains 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
import constate from "constate"; | |
import * as React from "react"; | |
import { | |
Connection, | |
subscribeEntities, | |
HassEntities, | |
AuthData, | |
Auth, | |
createConnection | |
} from "home-assistant-js-websocket"; |
This file contains 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
import * as React from 'react'; | |
import { QueryResult } from 'react-apollo'; | |
import { ApolloError } from 'apollo-client'; | |
export enum QueryRendererState { | |
LOADING, | |
EXPECTED_ERROR, | |
UNEXPECTED_ERROR, | |
READY, | |
} |