How to use can-list - 3 common examples

To help you get started, we’ve selected a few can-list 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
this.constructor.connection.deleteInstanceReference(this);
		callCanReadingOnIdRead = true;
		return CanMap.prototype._eventTeardown.apply(this, arguments);
	},
	// Change the behavior of `___set` to account for the store.
	___set: function (prop, val) {
		CanMap.prototype.___set.call(this, prop, val);
		// If we add or change the ID, update the store accordingly.
		// TODO: shouldn't this also delete the record from the old ID in the store?
		if ( prop === (this.constructor.id || "id") && this.__bindEvents && this.__bindEvents._lifecycleBindings ) {
			this.constructor.connection.addInstanceReference(this);
		}
	}
});

CanModel.List = CanList.extend({
	// ## CanModel.List.setup
	// On change or a nested named event, setup change bubbling.
	// On any other type of event, setup "destroyed" bubbling.
	_bubbleRule: function(eventName, list) {
		var bubbleRules = CanList._bubbleRule(eventName, list);
		bubbleRules.push('destroyed');
		return bubbleRules;
	}
},{
	setup: function (params) {
		// If there was a plain object passed to the List constructor,
		// we use those as parameters for an initial findAll.
		if (isPlainObject(params) && !Array.isArray(params)) {
			CanList.prototype.setup.apply(this);
			this.replace(canReflect.isPromise(params) ? params : this.constructor.Map.findAll(params));
		} else {
github canjs / can-connect / can / model / model.js View on Github external
setup: function (params) {
		// If there was a plain object passed to the List constructor,
		// we use those as parameters for an initial findAll.
		if (isPlainObject(params) && !Array.isArray(params)) {
			CanList.prototype.setup.apply(this);
			this.replace(canReflect.isPromise(params) ? params : this.constructor.Map.findAll(params));
		} else {
			// Otherwise, set up the list like normal.
			CanList.prototype.setup.apply(this, arguments);
		}
		this._init = 1;
		this.bind('destroyed', this._destroyed.bind(this));
		delete this._init;
	},
	_destroyed: function (ev, attr) {
github canjs / can-connect / can / model / model.js View on Github external
_bubbleRule: function(eventName, list) {
		var bubbleRules = CanList._bubbleRule(eventName, list);
		bubbleRules.push('destroyed');
		return bubbleRules;
	}
},{

can-list

Observable lists

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis