Skip to content

Commit

Permalink
Merge pull request canjs#1180 from bitovi/1162-fix-can-compute-docs
Browse files Browse the repository at this point in the history
move settings into a typedef, then reference it in the docs for can.compute
  • Loading branch information
daffl committed Oct 27, 2014
2 parents 5ce0b68 + 2d2ca93 commit 698aaa1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
17 changes: 1 addition & 16 deletions compute/compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ to the compute is.
age() //-> 30
age(31) //-> fires a "change" event

@param {{get: function, set: function, on: function, off: function}} [settings]
@param {computeSettings} [settings]

Configures all behaviors of the [can.computed compute]. The following cross
binds an input element to a compute:
Expand All @@ -54,21 +54,6 @@ binds an input element to a compute:
}
})

@option {function} get A function that retrieves and returns the current value
of the compute.

@option {function(*,*):*} set(newVal,oldVal)

A function that is called when a compute is called with an argument. The function is passed
the first argumented passed to [can.computed compute] and the current value. If
`set` returns a value, it is used to compare to the current value of the compute. Otherwise,
`get` is called to get the current value of the compute and that value is used
to determine if the compute has changed values.

@option {function(function)} on(updated) Called to setup binding to dependency events. Call updated
when the computes value needs to be updated.

@option {function(function)} off Called to teardown binding.

@return {can.computed} The new compute.

Expand Down
18 changes: 18 additions & 0 deletions compute/compute_settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@typedef {{get: function, set: function, on: function, off: function}} computeSettings computeSettings
@release 2.1
@parent can.compute

@option {function} get A function that retrieves and returns the current value of the compute.
@option {function(*,*):*} set(newVal,oldVal) A function that is used when setting a new value of the compute.

A function that is called when a compute is called with an argument. The function is passed
the first argumented passed to [can.computed compute] and the current value. If
`set` returns a value, it is used to compare to the current value of the compute. Otherwise,
`get` is called to get the current value of the compute and that value is used
to determine if the compute has changed values.

`newVal` is the value being set, while `oldVal` is the previous value in the compute.

@option {function(function)} on(updated) Called to setup binding to dependency events. Call `updated` when the compute's value needs to be updated.

@option {function(function)} off Called to teardown binding.

0 comments on commit 698aaa1

Please sign in to comment.