Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//!steal-remove-end
// Call event on the instance's Class
canEvent.dispatch.call(constructor, funcName, [instance]);
};
});
return behavior;
});
var CanModel = CanMap.extend({
setup: function (base, fullName, staticProps, protoProps) {
// Assume `fullName` wasn't passed. (`CanModel.extend({ ... }, { ... })`)
// This is pretty usual.
if (typeof fullName !== "string") {
protoProps = staticProps;
staticProps = fullName;
}
// Assume no static properties were passed. (`CanModel.extend({ ... })`)
// This is really unusual for a model though, since there's so much configuration.
if (!protoProps) {
//!steal-remove-start
dev.warn("can/model/model.js: CanModel extended without static properties.");
//!steal-remove-end
protoProps = staticProps;
}
_eventTeardown: function () {
callCanReadingOnIdRead = false;
this.constructor.connection.deleteInstanceReference(this);
callCanReadingOnIdRead = true;
return CanMap.prototype._eventTeardown.apply(this, arguments);
},
// Change the behavior of `___set` to account for the store.
_eventSetup: function () {
// this should not call reading
callCanReadingOnIdRead = false;
this.constructor.connection.addInstanceReference(this);
callCanReadingOnIdRead = true;
return CanMap.prototype._eventSetup.apply(this, arguments);
},
_eventTeardown: function () {
protoProps = staticProps;
staticProps = fullName;
}
// Assume no static properties were passed. (`CanModel.extend({ ... })`)
// This is really unusual for a model though, since there's so much configuration.
if (!protoProps) {
//!steal-remove-start
dev.warn("can/model/model.js: CanModel extended without static properties.");
//!steal-remove-end
protoProps = staticProps;
}
// Create the model store here, in case someone wants to use CanModel without inheriting from it.
this.store = {};
CanMap.setup.apply(this, arguments);
//
if (!CanModel) {
return;
}
// save everything that's not on base CanModel
// `List` is just a regular CanModel.List that knows what kind of Model it's hooked up to.
if(staticProps && staticProps.List) {
this.List = staticProps.List;
this.List.Map = this;
var Component = require("can-component");
var Map = require("can-map");
var ViewModel = Map.extend({
showThing: false
});
Component.extend({
tag: "home-page",
template: require("./home.stache!"),
ViewModel: ViewModel,
events: {
init: function(){
var vm = this.viewModel;
setTimeout(function(){
vm.attr("showThing", true);
}, 50);
}
}
});
var Component = require("can-component");
var Map = require("can-map");
require("can-map-define");
var List = require("can-list");
var ViewModel = Map.extend({
define: {
things: {
Value: List,
get: function(list){
var xhr = new XMLHttpRequest();
xhr.open("GET", "foo://bar");
xhr.onload = function(){
var data = JSON.parse(xhr.responseText);
list.replace(data);
};
xhr.send();
return list;
}
}
}
});
each(parseMethods, function(connectionName, name){
var fn = self.connection[connectionName].bind(self.connection);
fn.base = self[name];
CanMap._overwrite(self, base, name, fn);
});
},