Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.19 KB

README.md

File metadata and controls

41 lines (30 loc) · 1.19 KB

co-behavior

A Polymer behavior, implementing the co generator in Polymer. co is implemented as a behavior. A simple way to use it is as part of a a polymer function as below:

Published on webcomponents.org

<link rel="import" href="co-behavior.html">
....

class SomeClass extends Polymer.mixinBehaviors(
            [                                                                
                Polymer.CoBehavior
            ], Polymer.Element) {

__fetchStuff() {
    var self = this;
    return new Promise(function(resolve, reject) {
        .....
        resolve(stuff);
    });
}

__fetchSomething() {
    let something = function*() {
        let stuff = yield this.__fetchStuff.call(this);            
        this.someProperty = stuff;            
    };
    return this.co(something.call(this));
}

Install with:

bower install co-behavior --save-dev

Read more about co and generators here