Skip to content

Releases: canjs/canjs

v2.3.35

30 Apr 21:02
Compare
Choose a tag to compare

Re-publishing v2.3.34 due to the /dist/amd* folders being missing.

Fix can.batch.stop() to call ALL callbacks

20 Apr 19:10
Compare
Choose a tag to compare

v4.2.0

03 Apr 15:23
Compare
Choose a tag to compare

New Features

Tree Shaking

CanJS provides a new can/es module that contains named exports which can be imported and used to pluck out the parts that you need. When used in conjunction with tree shaking, you gain:

  • Fewer packages to import in each of your modules.
  • Bundles that exclude all of the parts of CanJS that you don’t use.

Get these benefits by importing the can/es module like so:

import { Component, DefineMap } from "can/es";

const ViewModel = DefineMap.extend({
	message: "string"
});

Component.extend({
	tag: "my-component",
	ViewModel
});

The above code will only import the required modules, not everything in can. To learn more, read the Experimental ES Module Usage docs.

can-dom-events v1.2.0 - Add jQuery’s special events to the global registry.

import $  from "jquery";
import addJQueryEvents from "can-dom-events/helpers/add-jquery-events";
import domEvents from "can-dom-events";

const removeJQueryEvents = addJQueryEvents($);

domEvents.addEventListener(listItemElement, "draginit", function listener() {
  // Will fire after a jQuery draginit event has been fired
});

$(listItemElement).trigger("draginit");
import Component from "can-component";
import domData from "can-dom-data";

Component.extend({
  tag: "todo-list",
  view: `
    <ul>
      {{#each(todos)}}
        <li {{domData("todo")}}>
          {{title}}
        </li>
      {{/each}}
    </ul>
  `,
  events: {
    "li click": function(element) {
      const todo = domData.get(element, "todo");
      // Do something with todo
    }
  }
});

Added Packages

can-attribute-observable - Create observables from HTML attributes.

import canReflect from "can-reflect";
import domEvents from "can-dom-events";
importvar AttributeObservable from "can-attribute-observable";

var input = document.createElement("input");
document.body.appendChild(input);

var obs = new AttributeObservable(input, "value", {});
canReflect.getValue(obs); // -> ""

canReflect.onValue(obs, function(newVal) {
    newVal; // -> "newVal"
});

input.value = "newVal";
domEvents.dispatch(input, "change");

can-define-backup

import DefineMap from "can-define/map/map";
import defineBackup from "can-define-backup";

const recipe = new DefineMap( "Recipe", {
    title: "Pancake Mix"
} );
defineBackup(recipe);

can-dom-data - Associate key/value pair data with a DOM node in a memory-safe way.

import domData from "can-dom-data";

const element = document.createElement("p");
document.body.appendChild(element);

domData.set(element, "metadata", {
  hello: "world"
});

let metadata = domData.get(element, "metadata");
// metadata is {hello: "world"}

Deprecations

can-stache v4.3.0 - {{data}} helper is deprecated in favor of {{domData}}

Bug Fixes

v3.13.1

13 Mar 13:23
Compare
Choose a tag to compare

Adding missing can-util functions to global namespace

This fix makes it so can-util functions are available on the can object in the global build.

so things like these will work again:

can.data
can.ajax
can.assign

v3.13.0

13 Mar 01:16
Compare
Choose a tag to compare

New Features

can-construct v3.3.0 - Set Constructor.name with Object.defineProperty

fixes uglify/minify problems with Constructor.name being removed

can-dom-events v1.1.0

can-fixture v1.2.0

can-reflect v1.8.0 - onInstanceBoundChange, defineInstanceKey, onInstancePatches, onPatches

From #77

  • defineInstanceKey(Type, key, descriptor) - define a key behavior on instances of a type
  • onInstanceBoundChange(Type, handler(instance, isBound) ) - listen to when instances of this type are bound or unbound
  • onInstancePatches(Type, handler(instance, patches) ) - listen to the patches events of all instances of this type
  • onPatches(obj, handler(patches)) - listen to patch events on this type

can-reflect v1.9.0 - Performance improvements

This speeds up .isObservable() and make it true if can.onPatches is present.

can-reflect v1.10.0

can-reflect v1.11.0 - 1.11.0

This release includes revised docs for canReflect.getName

can-reflect v1.12.0 - 1.12.0

  • Implements onInstancePatches / offInstancePatches

This release includes the base implementation of onInstancePatches / offInstancePatches which allow users to register / unregister a callback to fire when anything changes on any instance of the type passed in as an argument.

var Person = DefineMap.extend({});

canReflect.onInstancePatches(
  Person,

  // This function is called when any instance of the Person type changes
  function(instances, patches) {
  }
);

can-reflect v1.13.0 - canReflect.hasKey

canjs/can-reflect#95

can-set v1.4.0 - Algebra.has() does not check sorting nor pagination

Previously can-set.Algebra.has() operated somewhat similarly to can-set.Algebra.subset() in that it had a special treatment for when a set had sorting and pagination together, to ensure that sorting/order was checked first. This didn't make sense in the case of has() since it checks instance properties instead of sets, and instances in general do not know their own positions in sorted queries nor do they contain sort information of their own.

This has been released as a minor revision instead of a patch: even though no changes in the can-set tests nor documentation were necessary, we cannot guarantee that it won't break users' code relying on Algebra.has().

can-set v1.5.0 - Fix issues with Algebra.prototype.difference()

This release includes PR #82, which improved the difference() function for set.Algebra -- some differences involving paging were incorrect, now fixed, and differences involving ID fields are now supported as well. Also, undefined is no longer returned; the function now agrees with its documentation and returns false when A - B = A or A - B = ∅ (for sets A and B).

In addition, the documentation for union() in set.Algebra was updated to reflect the actual return value: false if the union cannot be expressed as a Set.

can-symbol v1.5.0 - onPatches offPatches

Documents the onPatches and offPatches symbols and what patch objects look like:

add patches signal that a key was added to an object.

{type: "add", key: "b", value: 1}

delete patches signal that a key was deleted from an object.

{type: "delete", key: "a"}

set patches signal that an existing key's value was set to another value.

{type: "set", key: "c", value: 2}

splice patches signal a list-like object had enumerable values added, removed
or both at a specific index.

{type: "splice", index: 0, deleteCount: 10, insert: [item1, item2]}

move patches signal a list-like object had an enumerable value move from one
position to another.

{type: "move",   fromIndex: 1, toIndex: 2}

values patches signal a container-like object (like Set) has
had items added or removed.

{type: "values", delete: [item0], insert: [item1, item2]}

can-stache v3.14.0 - addHelper, addLiveHelper, {{#each(list)}} performance

canjs/can-stache#367

  1. Adds addHelper in place of registerSimpleHelper (and deprecates registerSimpleHelper):
stache.addHelper("upper", function(str){
	return str.toUpperCase();
});
  1. Adds addLiveHelper for helpers that handle observability themselves and do not need to be passed computes:
stache.addLiveHelper("upper", function(str){
	if (canReflect.isObservable(str) && canReflect.isValueLike(str)) {
		str = canReflect.getValue(str);
	}

	return str.toUpperCase();
});
  1. Fixes each helper to correctly use can-view-live.list when passed a compute that wraps a list instead of re-rendering the entire list:
var view = stache(`
{{#each(list)}}
  {{.}}
{{/each}}
`);

var listCompute = new compute([ "one", "two" ]);

document.body.appendChild(
  view({ list: listCompute })
);

listCompute(["one", "two", "three"]);

can-stache-converters v3.3.0 - Add selected-to-index, updated docs, and added cycle detection

  • Update docs to use new binding syntax #52
  • add selected-to-index #57
  • Add a cycle detection script to test process #56
  • Update docs with new @parent & @collection #59

canjs/can-stache-converters@v3.2.2...v3.3.0

can-symbol v1.6.0 - hasKey

canjs/can-symbol#24

can-util v3.11.0 - Add string.replaceWith()

This minor release adds can-util/js/string/string.replaceWith, see PR #402.

can-validate-legacy v1.2.0

can-zone v0.6.15 - 0.6.15

This is a minor release, adding the following features:

  • Subclassable Zone

The Zone constructor can now be subclassed. This is useful in case you need to isolate Zone.current when run in an environment where you can't capture async tasks by calling a function. An example would be if using iframes:

var Zone = require("can-zone");

var SubZone = class extends Zone {};

var zone = new SubZone();
SubZone.current = zone;

// Now you can do stuff with `zone` and it won't touch
 `Zone.current`.
  • Break on timeout

You can now get a debugger; statement when using can-zone/debug, allowing you to step into code that is preventing the zone's run promise from resolving.

var Zone = require("can-zone");

var zone = new Zone([
  debug(5000, { break: true });
]);

break on timeout

  • New documentation

Some missing documentation was added for:

  • afterTask: A hook that is called at the end of a Task.
  • globals: A property on the ZoneSpec that allows you to specify globals that should be replaced inside of the zone.
  • Issues
  • can-zone v0.6.16 - 0.6.16
    This patch release moves debug-on-timeout in the can-zone/debug plugin to occur when the asynchronous function is called, rather than when the callback is called. This makes it easier to look back in the call stack and figure out why the asynchronous code is still running after a timeout is complete.

can-zone v0.6.17 - 0.6.17

  • Wrap event handlers set with .on[event] = handler syntax.

This patch release makes it so can-zone wraps event handlers like the following:

var div = document.createElement("div");

// handleClick should run within the current zone now.
div.onclick = function handleClick() {
};

Deprecations

Bug Fixes

Read more

v4.1.1

08 Mar 15:22
Compare
Choose a tag to compare

When using can.all.js the Enter event is now enabled by default. This fixes issues with JSBins and anything else using the global build and trying to call functions using on:enter="...".

#4017

v4.1.0

05 Mar 21:19
Compare
Choose a tag to compare

Added Packages

can-map-define v4.0.0

New Features

can-observe v2.1.0 - Rich Property Behaviors and Decorators

can-observe now supports an extensible system for defining rich property behaviors, by providing an observable-returning function to defineProperty function. This becomes even more reusable when these behaviors are defined inside decorators. We have also provided built-in decorators for async and resolver;

can-route v4.1.0 - route.stop()

This releases adds a new feature, route.stop(). This can be used to unbind can-route from an observable. This could be used if you needed to change to use a different observable.

import route from "can-route";

route.register("{page}");

route.data = new ViewModel();
route.start();

route.stop();
route.data = new OtherViewModel();
route.start();

can-stache v4.1.0 - Add directlyNested tagData

For canjs/can-stache#464

can-stache-bindings v4.1.0 - Provides a new type of binding for string values

This introduces the raw binding type. When the new binding syntax was introduce it didn't provide a good way to pass string values like was possible in the 2.3 syntax. 4.1.0 introduces a raw binding so that instead of wrapping strings in quotes like so:

<some-element prop:from="'Some value'">

You can use:

<some-element prop:raw="Some value">

Deprecations

can-stache v4.2.0 - Use can-stache-ast and deprecate intermediate_and_imports

This deprecated can-stache/src/intermediate_and_imports in favor of the can-stache-ast package.

Other Updates

can-attribute-encoder

can-component

can-compute

// oldVal was passed to the change event callback as expected
compute.on("change", function(newVal, oldVall) {
   // oldVal was being set correctly here
});

// but it was always undefined when using canReflect.onValue
canReflect.onValue(compute, function(newVal, oldVal) {
  // oldVal always `undefined`
});

canjs/can-compute#129

can-connect

can-construct

can-control

can-debug

can-define

can-define-lazy-value

can-define-stream

can-define-validate-validatejs

can-dom-events

See canjs/can-dom-events#41

Edge 14 has no support for Element.prototype.matches but it implements the same functionality as Element.prototype.msMatchesSelector.

can-dom-mutate

can-event-queue

can-fixture

can-globals

can-kefir

can-key-tree

can-map

🎉

can-ndjson-stream

can-observation

can-observation-recorder

can-observe

can-param

can-queues

can-reflect

can-reflect-dependencies

can-route

can-route-pushstate

See canjs/can-route-pushstate#91

can-set

can-simple-map

[can-simple-observable](https://github.com/canjs/can-simple-observable/r...

Read more

v3.12.1

13 Nov 20:19
Compare
Choose a tag to compare

Dependency patch updates (#3733):

  • can-util@3.10.15
  • can-event-dom-enter@1.0.4
  • can-event-dom-radiochange@1.0.4
  • can-view-import@3.2.5

v3.12.0

03 Nov 02:58
Compare
Choose a tag to compare

New Features

can-stache

can-stache v3.13.0: Adding scope.root

This adds a {{scope.root}} that you can use to access the data passed to a stache renderer function. This allows you to avoid scope walking with recursive partials:

const data = new DefineMap({
    name: "Earthworm Jim",
    child: {
        name: "Grey Worm",
        child: {
            name: "MyDoom"
        }
    },
    exclaim: '!!!'
});

const view = stache("AppTemplate", `
    {{<personAndChildren}}
        <span>{{name}} {{scope.root.exclaim}}</span>
        {{#./child}}
            <div>
                {{>personAndChildren this}}
            </div>
        {{/./child}}
    {{/personAndChildren}}

    {{>personAndChildren this}}
`);

Learn more in the scope.root docs.

can-stache v3.12.0: Moving %special keywords to scope keyword

This deprecates the %special keywords and moves them into a new scope keyword:

  • %index -> scope.index
  • %key -> scope.key
  • %element -> scope.element
  • %event -> scope.event
  • %viewModel -> scope.viewModel
  • %arguments -> scope.arguments

This also adds two new keywords:

  • scope.filename
  • scope.lineNumber

Learn more in the scope docs.

can-stache-bindings

can-stache-bindings v3.11.0: Moving %special keywords to scope keyword

The %special keywords are now available on a new scope keyword:

%element -> scope.element
%event -> scope.event
%viewModel -> scope.viewModel
%arguments -> scope.arguments

Learn more in the scope docs.

can-stache-converters

can-stache-converters v3.3.0

Added selected-to-index.

can-route-pushstate

can-route-pushstate v3.2.0: Document replace state and other docs improvements

Read the replace state docs in the “Updating the current route” section of the can-route-pushstate docs.

can-ajax

can-ajax v1.1.0: Implement ajaxSetup

The ajaxSetup method is now available for reverse compatibility with $.ajaxSetup.

Example usage:

var ajax = require("can-ajax");
ajax.ajaxSetup({
  lang: "de"
});

The above will set the language to German for each request generated by can-ajax.

The xhrFields option is also now available in calls to ajax.ajaxSetup() and ajax():

ajax({
    type: "GET",
    url: "https://example.com/api/users",
    xhrFields: {
      withCredentials: true
    }
 });

Enables CORS for the cross-domain request.

can-view-model

can-view-model v3.5.0: Document the API changes from 3.2.0

With version 3.2.0, can-view-model gained the ability to read the view model of an element from a jQuery, array-like, or selector string. This was not documented at the time, but is now officially part of the API.

Learn more in the can-view-model docs.

can-map

can-map v3.4.0: Permissive handling for properties with dots.

With can-map 3.2.0, handling of dotted properties (e.g. "foo.bar" as a property key in a can-map) was updated to throw fewer errors and allow more cases, but this was not documented as official behavior in the API.

In this release, we’ve made those changes official in the API.

For more information, see the Properties with dots in their name section in the attr docs.

can-reflect

can-reflect v1.6.0: getPriority and setPriority

var obj = canReflect.assignSymbols({},{
  "can.setPriority": function(priority){
    return this.priority = priority;
  }
});

canReflect.setPriority(obj, 0) //-> true
obj.priority //-> 0

canReflect.setPriority({},20) //-> false

Learn more in the getPriority and setPriority docs.

can-reflect v1.5.0: assignSymbols works with symbols on Symbol

var list = ["a","b","c"];
canReflect.assignSymbols(list,{
    "can.onPatches": function(){

    },
    "iterator": function(){
      return list[Symbol.iterator]()
    }
})

Learn more in the assignSymbols docs.

can-dom-events

can-dom-events v1.0.0: Major Event

This is now a real project, which is a replacement (along with can-event-dom-* events) for can-util/dom/events. So here are the steps to migrate from that to this.

- var domEvents = require('can-util/dom/events/events');
+ var domEvents = require('can-dom-events');
- domEvents.addEventListener.call(target, eventType, handler);
+ domEvents.addEventListener(target, eventType, handler);
- domEvents.removeEventListener.call(target, eventType, handler);
+ domEvents.removeEventListener(target, eventType, handler);
- domEvents.dispatch.call(target, eventType, eventArgs, bubbles);
+ domEvents.dispatch(target, eventType | eventData, bubbles);

Learn more in the can-dom-events docs.

can-simple-dom

can-simple-dom v1.3.0: Add textContent

1.3.0 updates can-simple-dom to support the textContent as a getter/setter on the Element prototype. This will create a TextNode as the only child node to the element.

can-symbol

can-symbol v1.2.0: can.assignDeep and can.updateDeep

Adds docs for can.assignDeep and can.updateDeep.

can-view-parser

can-view-parser v3.6.0: Better Debug Messages

Track line numbers, including them in handler.*() calls and parsing warnings.

Other Updates

This is not an exhaustive list; packages that only included dependency, docs, or test updates are not included below.

can-component

  • can-component v3.3.6: Various docs improvements

  • Update can-component docs with new binding syntax #149

  • Remove deprecated can-util methods and replace with can-globals #148

  • can-component v3.3.5: Fix leakScope behavior with Helpers

    • Helpers did not respect the leakScope flag which caused components to leak their helpers to child components.

This release fixes this so that helpers are only available to the current component, just as expected with leakScope set to false.

  • Issue: #77
  • PR: #155
  • can-component v3.3.4: warns if viewModel is assigned a DefineMap

can-connect

  • can-connect v1.5.9: Use can-ajax directly
    • This release removes the warning about using can-util/dom/ajax/ajax due to that function having moved out to the can-ajax module. This release directly imports and uses can-ajax.

can-jquery

  • can-jquery v3.2.3: Add Check for $
    • Make sure $ is not undefined before adding functionality.
  • can-jquery v3.2.2: Fix dependency conflict
      • Fix dependency conflicts #141

can-cid

can-ndjson-stream

can-control

  • can-control v3.2.2: Updating can-stache-key to receive bug fixes

can-connect-feathers

can-element

  • can-element v0.2.2: Update minimum can-view-scope dependency
    • can-view-scope prior to v3.3.6 had a bug that prevented can-element from working correctly. This release sets the minimum version of can-view-scope to 3.3.6 to prevent issues with assigning a references scope for the element callback.

This release also adds a cyclic dependency detection script to the test process.

can-define-stream-kefir

can-map-define

  • can-map-define v3.1.1: Undeprecated Array
    • This patch release is ...
Read more

v3.11.0

06 Oct 21:36
Compare
Choose a tag to compare

New Features

can-cid

can-connect-feathers

  • can-connect-feathers v3.7.0: Support 2FA response types in session behavior

can-define

can-define v1.5.0: Deprecate .set(Object)

DefineMap and DefineList have the .set() function for setting possibly-unknown keys to provided values. .set had a pattern that took an object and set properties based on the keys of the object. This is now deprecated in favor of the following functions:

  • .assign(Object) shallow-copies the properties of the object to the DefineMap/DefineList (object values are replaced). Existing keys on the map or list not part of the provided object are preserved.
  • .assignDeep(Object) deep-copies the properties of the object to the DefineMap/DefineList (object values are merged). Existing keys on the map or list not part of the provided object are preserved.
  • .update(Object) shallow-copies the properties of the object to the DefineMap/DefineList (object values are replaced). Existing keys on the map or list not part of the provided object are not preserved.
  • .updateDeep(Object) deep-copies the properties of the object to the DefineMap/DefineList (object values are merged). Existing keys on the map or list not part of the provided object are not preserved.

can-reflect

  • can-reflect v1.4.0: size, assign[Deep], update[Deep]
    • This documents size, assign, update, assignDeep and updateDeep.
  • can-reflect v1.3.0: Support [Weak][Map|Set]

can-simple-dom

  • can-simple-dom v1.3.0: Add textContent
    • 1.3.0 updates can-simple-dom to support the textContent as a getter/setter on the Element prototype. This will create a TextNode as the only child node to the element.
  • can-simple-dom v1.2.0: Add no-op CSSStyleDeclaration.getPropertyValue method

can-stache

You can now use a hash expression for creating variables localized to an {{#each}} loop.

You can use this when using {{#each}} to iterate over arrays to access the index and value for each item in the array:

{{#each todos todo=value num=index}}
    <li>Todo {{num}}: {{todo.name}}</li>
{{/each}}

You can also use this to access the key and value for each item when iterating over an object:

{{#each person propValue=value prop=key}}" +
    <span>{{prop}}: {{propValue}}</span>
{{/each}}

This also deprecates the {{#each EXPRESSION as KEY}} syntax.

  • can-stache v3.8.0: Use hash keys instead of an object in {{#with}}
    • The {{#with}} helper adds a new scope context (becoming the current this) and renders the subsection it contains. Prior to 3.8.0, the semantics for {{#with}} involved choosing an object on the scope to become this new context.
{{#with scopeObject}}
  <span>{{./propertyOnScopeObject}}</span>
{{/with}}

With 3.8.0, you now have the option to construct your own context object using hash expressions.

{{#with key=scopeLookup key2=anotherLookup}}
   <span>{{./key}}: {{key2}}</span>
{{/with}}

In addition, the behavior of {{#with}} with a context object was incorrect with respect to the documented behavior. Prior to 3.8.0, the subsection inside {{#with}}...{{/with}} would not render if passed a falsy object (the same behavior as creating a section with {{#}}). This was not the intended or documented behavior and has been fixed. Now the subsection always renders.

Note: this feature and behavior fix were added in version 3.7.3, which has now been deprecated in favor of this minor release due to the documented new feature.

  • can-stache v3.7.0: Self-referential Templates
    • Added *self as a partial that refers to the whole template renderer.
var grandpaWorm = new DefineMap({
	name: "Earthworm Jim",
	child: {
		name: "Grey Worm",
		child: {
			name: "MyDoom"
		}
	}
});

var renderer = stache(`
	<span>{{name}}</span>
	{{#./child}}
		<div>
			{{>*self}}
		</div>
	{{/child}}
`);

var view = renderer(grandpaWorm);

The view variable will be a document fragment:

<span>Earthworm Jim</span>
<div>
	<span>Grey Worm</span>
	<div>
		<span>MyDoom</span>
	</div>
</div>

can-react-component v0.1.8: React 16 Support

can-symbol

  • can-symbol v1.2.0: can.assignDeep and can.updateDeep
  • can-symbol v1.1.0: can.size and can.updateValues

Adds can.size and can.updateValues

can-vdom

  • can-vdom v3.2.0: 3.2.0
    • This is a minor release adding the Node type to the exported globals in can-vdom/make-window/make-window.
var makeWindow = require("can-vdom/make-window/make-window");

var window = makeWindow();

assert.equal(window.Node.TEXT_NODE, 3, "The nodeTypes are all exported");

#22 Expose the Node global

can-view-model

  • can-view-model v3.5.0: Document the API changes from 3.2.0
    • With version 3.2.0, can-view-model gained the ability to read the view model of an element from a jQuery, array-like, or selector string. This was not documented at the time, but is now officially part of the API.

can-stache-bindings

  • can-stache-bindings v3.9.0: Documentation for on:input:value:to
    • on:input:value:to documented under Syntaxes on:event and toParent:to.
  • can-stache-bindings v3.8.0: Deprecation of legacy binding syntax

It also includes a bug fix for canjs/can-stache-bindings#289

  • can-stache-bindings v3.7.1: Support properties with dots (.) in the path
    • This version of can-stache-bindings updates the minimum dependency on can-stache to 3.7.1, to fix an issue with properties on the context object that contain a dot. For example, the input generated by this stache:
<input value:bind="['foo.bar']" />

will now be able to set the property named "foo.bar" on the context object on value updates. This is different from <input value:bind="foo.bar" />, which sets the property named "bar" on the property named "foo" on the context.

Also contained in this release: a minor doc update that points to the "at" key lookup operator in can-stache.

Bug fixes:


react-view-model v0.5.8 - React 16 Support

New Packages

can-ajax

Make AJAX Requests.

var ajax = require("can-ajax");

ajax({
  url: "http://query.yahooapis.com/v1/public/yql",
  data: {
    format: "json",
    q: 'select * from geo.places where text="sunnyvale, ca"'
  }
}).then(function(response){
  console.log( response.query.count ); // => 2
});

can-define-lazy-value

Use Object.defineProperty to define properties whose values will be created lazily when they are first read.

var _id = 1;
function getId() {
    return _id++;
}

function MyObj(name) {
    this.name = name;
}

defineLazyValue(MyObj.prototype, 'id', getId);

var obj1 = new MyObj('obj1');
var obj2 = new MyObj('obj2');

console.log( obj2 ); // -> { name: "obj2" }
console.log( obj1 ); // -> { name: "obj1" }

// the first `id` read will get id `1`
console( obj2.id ); // -> 1
console( obj1.id ); // -> 2

console.log( obj2 ); // -> { name: "obj2", id: 1 }
console.log( obj1 ); // -> { name: "obj1", id: 2 }

can-simple-observable

Create an observable value.

 var obs = observable('one');

 canReflect.getValue(obs); // -> "one"

 canReflect.setValue(obs, 'two');
 canReflect.getValue(obs); // -> "two"

 function handler(newValue) {
   // -> "three"
 };
 canReflect.onVa...
Read more