can-observe
Version:
Like can.Map, but without the .attr method.
33 lines (25 loc) • 931 B
Markdown
as an API request or a promise.
When attached to a method, it passes a `resolve` argument, which you call to set the value. When attached to a getter, it expects the return value to be a promise (specifically, a thenable) or undefined (for no changes);
```js
import observe from "can-observe";
class Thing extends observe.Object {
@ .async
fullName( resolve ) {
setTimeout( function() {
resolve( this.first + " " + this.last );
}.bind( this ), 0 );
}
@ .async
get formalName() {
return new Promise( ( resolve ) => {
setTimeout( function() {
resolve( this.last + ", " + this.first );
}.bind( this ), 0 );
} );
}
}
```
{function} can-observe.async async
can-observe/decorators
Create observable key-value instances or types.
` .async`
The ` ` decorator sets up the value to be connected to the result of an asynchronous call, such