Skip to content

Commit

Permalink
updating design to include sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed Jun 29, 2016
1 parent 7fc96cd commit 0dc9cd9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
55 changes: 49 additions & 6 deletions docs/can-canjs/can-core.md
Expand Up @@ -15,12 +15,59 @@ should install the ones you use directly:
npm install can-define can-set can-connect can-component can-stache can-route --save
```

Lets export each one a bit more in detail.
Lets export each one a bit more.

## can-compute

[can-compute]s represent an observable value. A compute can contain its
own value and notify listeners of changes like:

```js
var compute = require("can-compute");

var name = compute("Justin");

// read the value
name() //-> "Justin"

name.on("change", function(ev, newVal, oldVal){
newVal //-> "Matthew"
oldVal //-> "Justin"
});

name("Matthew");
```

More commonly, a compute derives its value from other observables:

```js
var DefineMap = require("can-define/map/map"),
DefineList = require("can-define/list/list"),
compute = require("can-compute");

var person = new DefineMap({first: "Justin", last: "Meyer"}),
hobbies = new DefineList(["js","bball"]),
age = compute(33);

var info = compute(function(){
return person.first +" "+ person.last+ " is "+age()+
"and like "+hobbies.join(", ")+".";
});

info() //-> "Justin Meyer is 33 and likes js, bball."

info.on("change", function(ev, newVal){
newVal //-> "Justin Meyer is 33 and likes js."
});

hobbies.pop();
```


## can-define

[can-define/map/map] and [can-define/list/list] allow you to create observable
objects with well defined properties. You can
maps and lists with well defined properties. You can
[can-define.types.propDefinition define a property's type initial value, enumerability, getter-setters and much more].
For example, you can define the behavior of a `Todo` type and a `TodoList` type as follows:

Expand Down Expand Up @@ -411,7 +458,3 @@ mixes in this behavior so you just need to import the module:
var route = require("can-route");
require("can-route-pushstate");
```
## can-compute
?
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -85,7 +85,7 @@
"bit-docs-dev": "^0.0.3",
"bit-docs-js": "^0.0.5",
"bit-docs-generate-html": "^0.0.5",
"bit-docs-html-canjs": "^0.0.10",
"bit-docs-html-canjs": "^0.0.11",
"bit-docs-prettify": "^0.0.3"
},
"glob": {
Expand Down

0 comments on commit 0dc9cd9

Please sign in to comment.