How to use the can-map.extend function in can-map

To help you get started, we’ve selected a few can-map examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github canjs / can-connect / can / model / model.js View on Github external
//!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;
		}
github donejs / autorender / test / async / home / home.js View on Github external
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);
		}
	}
});
github donejs / autorender / test / async / other / other.js View on Github external
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;
			}
		}
	}
});

can-map

Observable Objects

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis