How to use can-map - 7 common examples

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 canjs / can-connect / can / model / model.js View on Github external
_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.
github canjs / can-connect / can / model / model.js View on Github external
_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 () {
github canjs / can-connect / can / model / model.js View on Github external
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;
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;
			}
		}
	}
});
github canjs / can-connect / can / model / model.js View on Github external
each(parseMethods, function(connectionName, name){
			var fn = self.connection[connectionName].bind(self.connection);
			fn.base = self[name];
			CanMap._overwrite(self, base, name,  fn);
		});
	},

can-map

Observable Objects

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis