Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

On can.Observe -> can.Map

$
0
0


This has been in the works for a while: https://github.com/bitovi/canjs/issues/374

  There's a few reasons for this change.

Observe isn't what it does ...

can.Observe doesn't actually observe anything. Instead, it is an observable object (or map).

Observe / List / Compute weirdness

It's strange to have Observe next to List and Compute as CanJS's list of observables.

So want to change it (while being backwards compat for 1.2) to:

can.List
can.Map

An alternative was:

can.Array
can.Object

We favored can.Map for 2 reasons:

1.  There are Maps in ES6 which will be pretty similar: http://www.nczonline.net/blog/2012/10/09/ecmascript-6-collections-part-2-maps/. Although can.Map will not immediately allow you to map using arbitrary ids.

2. can.Array and can.Object would be a bit strange, especially as instance of can.Array would be false.

List and Map are not perfect names, and we are open to suggestions. We've debated it quite a bit internally at Bitovi. But List and Map are certainly better than:

can.Observe.List
can.Observe

Btw, it's possible that can.compute will be split between can.observable and can.compute.  This would allow us to more easily explain:

CanJS's observable set:

can.Map -> Objects and maps.
can.List -> Arrays and ordered collections.
can.observable -> values
can.compute -> values derived from other values

But, I want to keep 

Viewing all articles
Browse latest Browse all 3491

Trending Articles