-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from canjs/130-value-api
Add a value property getter
- Loading branch information
Showing
4 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@property can-observation.prototype.value value | ||
@parent can-observation.prototype | ||
@description Reads the value of the observation. | ||
@signature `observation.value` | ||
|
||
The following creates a `fullName` observation that derives its values from | ||
the `person` observable. The value of the observation is read with | ||
`fullName.value`: | ||
|
||
```js | ||
import Observation from "can-observation"; | ||
import observe from "can-observe"; | ||
|
||
const person = observe( { first: "Grace", last: "Hopper" } ); | ||
|
||
const fullName = new Observation( function() { | ||
return person.first + " " + person.last; | ||
} ); | ||
|
||
fullName.value; //-> "Grace Hopper"; | ||
``` |